VB.net 简单程序的结构 (注意和VB过程的区别)

来源:互联网 发布:linux查询cpu使用情况 编辑:程序博客网 时间:2024/05/15 23:40

Imports System.IO
Public Class Form1
    Dim s1, s2, s3, s4, s5
    Dim search As String
    Dim a As Integer

----------------------------------------------------------------------------------------------------------------------------------------------------
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    End Sub

----------------------------------------------------------------------------------------------------------------------------------------------------
    Private Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        s1 = "Familiar concepts, language, and real-world conventions in an interface can take advantage of knowledge users already have and, therefore, can make the interface more familiar and easier to use. "
        TextBox1.Text = s1    '按下button1  输出S1的内容到TextBox1
    End Sub

----------------------------------------------------------------------------------------------------------------------------------------------------

    Private Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
        s2 = "Making use of users' prior knowledge of and experience with other parts of the same application and other applications on the same platform will make an interface more familiar and easier to use."
        TextBox1.Text = s2    '按下button1  输出S1的内容到TextBox1
    End Sub

----------------------------------------------------------------------------------------------------------------------------------------------------

    Private Sub Button3_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button3.Click
        s3 = "This heuristic relates to the visual search aspect of perception and also to memory. The more clutter, the more information the user's eyes must search through to find the desired information. In addition, the more information coming into a user's working memory through perception as a visual search proceeds, the more information there is to interfere with the retrieval from long-term memory of the information that is relevant to the task. "
        TextBox1.Text = s3      '按下button1  输出S1的内容到TextBox1
    End Sub

----------------------------------------------------------------------------------------------------------------------------------------------------

    Private Sub Button4_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button4.Click
        s4 = "Errors can come about because users make mistakes in perception, lack knowledge of what to do next, recall the gist of commands rather than the precise syntax—or they may simply slip when they go to type or point. Some of these mistakes can be prevented by, say, an interface only showing the actions that are acceptable at a particular point (for example, by graying out inappropriate buttons). Other mistakes can be caught as soon as users make them (for example, by the interface refusing to accept an incorrect abbreviation of a U.S. state in an address form). "
        TextBox1.Text = s4      '按下button1  输出S1的内容到TextBox1
    End Sub

----------------------------------------------------------------------------------------------------------------------------------------------------

    Private Sub Button5_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button5.Click
        s5 = "This heuristic is an admonition to give the user enough information to understand how to use an application. An application's search feature should allow desired information to be found when a user specifies the gist of its meaning rather than precise wording: people usually remember only gists, not exact wordings. "
        TextBox1.Text = s5      '按下button1  输出S1的内容到TextBox1
    End Sub

----------------------------------------------------------------------------------------------------------------------------------------------------

    Private Sub Button6_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button6.Click
        s1 = "Familiar concepts, language, and real-world conventions in an interface can take advantage of knowledge users already have and, therefore, can make the interface more familiar and easier to use. "
        s2 = "Making use of users' prior knowledge of and experience with other parts of the same application and other applications on the same platform will make an interface more familiar and easier to use."
        s3 = "This heuristic relates to the visual search aspect of perception and also to memory. The more clutter, the more information the user's eyes must search through to find the desired information. In addition, the more information coming into a user's working memory through perception as a visual search proceeds, the more information there is to interfere with the retrieval from long-term memory of the information that is relevant to the task. "
        s4 = "Errors can come about because users make mistakes in perception, lack knowledge of what to do next, recall the gist of commands rather than the precise syntax—or they may simply slip when they go to type or point. Some of these mistakes can be prevented by, say, an interface only showing the actions that are acceptable at a particular point (for example, by graying out inappropriate buttons). Other mistakes can be caught as soon as users make them (for example, by the interface refusing to accept an incorrect abbreviation of a U.S. state in an address form). "
        s5 = "This heuristic is an admonition to give the user enough information to understand how to use an application. An application's search feature should allow desired information to be found when a user specifies the gist of its meaning rather than precise wording: people usually remember only gists, not exact wordings. "
        search = TextBox2.Text
        If Len(search) = 0 Then
            TextBox1.Text = "Please enter a valid search string."
            TextBox2.Focus()
            If Len(search) < 3 Then TextBox1.Text = "Please enter a string that is 3 characters or longer."
            TextBox2.Focus()
        Else
            a = InStr(s1, search)
            If a <> 0 Then                         '若S1中搜索结果不为0,则输出S1
                TextBox1.Text = "Match between system and the real world:" + vbCrLf + vbCrLf + s1
            Else
                a = InStr(s2, search)              '若S2中搜索结果不为0,则输出S1
                If a <> 0 Then
                    TextBox1.Text = "Consistency and standards:" + vbCrLf + vbCrLf + s2
                Else
                    a = InStr(s3, search)          '若S3中搜索结果不为0,则输出S1
                    If a <> 0 Then
                        TextBox1.Text = "Aesthetic and minimalist design:" + vbCrLf + vbCrLf + s3
                    Else
                        a = InStr(s4, search)      '若S4中搜索结果不为0,则输出S1
                        If a <> 0 Then
                            TextBox1.Text = "Help users recognize, diagnose, and recover from errors:" + vbCrLf + vbCrLf + s4
                        Else
                            a = InStr(s5, search)  '若S5中搜索结果不为0,则输出S1
                            If a <> 0 Then         '若S1-S5都搜索结果数为0,则输出提示
                                TextBox1.Text = "Help and documentation:" + vbCrLf + vbCrLf + s5
                            Else
                                TextBox1.Text = "No Match Found"
                            End If
                        End If
                    End If
                End If
            End If
        End If
    End Sub

    Private Sub Textbox2_Change()
        TextBox1.Text = ""
    End Sub

----------------------------------------------------------------------------------------------------------------------------------------------------End Class