Public Class Form1
Private Const _UserNameC As String = "Tanker.Z" '常量声明 用 Const
Private Const _UserPasswordC As String = "Jereh"
Private Const _StringEmptyC As String = ""
Dim nValue As Integer '声明变量方式
''' <summary>
''' ByVal 传值 ByRef 传引用
''' Sub 是过程 无返回值 Function 是 函数 必须有返回值
''' VB.NET不用;符号来做结束String.Empty
''' And 表示 与关系 Or表示 或关系
''' </summary>
''' <param name="sender"></param>
''' <param name="e"></param>
''' <remarks></remarks>
Private Sub btnLogin_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles btnLogin.Click
If txtUserName.Text.Trim() = String.Empty Or txtUserPassword.Text.Trim() = _StringEmptyC Then
nValue = StrComp("A","B") 'StrComp()函数 若 A>B则返回1,若想等则返回0 若 A<B则返回 -1 所有返回值均为整数
MsgBox(nValue)
Else
If CheckLogin(txtUserName.Text,txtUserPassword.Text) Then
Debug.Print("哦...........")
Console.WriteLine("う..........Hello Friend")
'那怎么才能看到打印的Hello Friend。
'这里需要在visual studio2010: Debug--》windows--》Output 。
Else
MsgBox("い.....")
End If
End If
End Sub
''' <summary>
'''
''' </summary>
''' <param name="userName"></param>
''' <param name="userPwd"></param>
''' <returns></returns>
''' <remarks></remarks>
Private Function CheckLogin(ByVal userName As String,ByVal userPwd As String) As Boolean
If StrComp(_UserNameC,userName) = 0 And StrComp(_UserPasswordC,userPwd) = 0 Then
Return True
End If
Return False
End Function
End Class
原文链接:https://www.f2er.com/vb/260712.html