新建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
如果需要判断大小写,请先整理。