這次的程式有加上註解 讓不會的人比較容易懂 程式還有有些地方有小bug 請見諒                                                            

Partial Class _Default

    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim UserInput As String

        Dim a As String = TextBox1.Text

        Dim wr As String = ""                                        ///// 定義wr的字串為幹

        Dim wr1 As String = ""                                      ///// 定義wr1的字串為操  

        Dim wr2 As String = "fuck"                                 ///// 定義wr2的字串為fuck

        Dim test As Integer = a.IndexOf(wr)              /////顯示test是否符合符合就顯示為0

        Dim test1 As Integer = a.IndexOf(wr1)            /////顯示test1是否符合符合就顯示為0

        Dim test2 As Integer = a.IndexOf(wr2)            /////顯示test2是否符合符合就顯示為0

      If test <> -1 OrElse test1 <> -1 OrElse test2 <> -1 Then

///// test1,2,3其中有一個為髒話就跳出字串顯示要有禮貌並且刪除輸入的字

            TextBox2.Text = "沒教養的小孩 請輸入文雅的字"

        ElseIf test <> -1 OrElse test1 <> -1 OrElse test2 <> -1 Then

            UserInput = " "

        Else

            UserInput = TextBox1.Text.Replace(" ", "&nbsp;")

            UserInput = UserInput.Replace(vbCrLf, "<br />")

            UserInput = Now.ToString & "<br />" & UserInput

            Label3.Text = "<hr />" & UserInput & Label3.Text

        End If

    Protected Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

        Dim a As String = TextBox1.Text

        Dim i As Integer = a.Length                             /////顯示字數統計

        TextBox3.Text = i

    End Sub

End Class

 

 

ps.若有不會的地方請多多請教別人 謝謝 by jet

 

創作者介紹
創作者 jethro0119 的頭像
jethro0119

滷蛋與貢丸

jethro0119 發表在 痞客邦 留言(0) 人氣()