首页 /编程语言和算法/VB6/ASP
 VB6 检查前面是否一样的子程序 f_chkLeft(strL As String, strC As String)
4月24日 15:36

新建From1(窗体),新建Command1(按钮CommandButton),代码:

Private Function f_chkLeft(strL As String, strC As String)
    If Left(strL, Len(strC)) = strC Then
        f_chkLeft = True
    Else
        f_chkLeft =  False
    End If
End Function

Private Sub Command1_Click()
    Dim strL As String
    strL = "hello"
    MsgBox f_chkLeft(strL, "he")
End Sub

运行结果:

True

如果需要判断大小写,请先整理。

 
全部回复(0)
首页 | 电脑版 |