鉴于:
原文链接:https://www.f2er.com/vb/255983.htmlDim strOrig = "010451-09F2"
您可以执行以下任何操作:
Dim leftString = strOrig.Substring(0,strOrig.IndexOf("-"))
要么:
Dim leftString = strOrig.Split("-"c)(0) ' Take the first index in the array
要么:
Dim leftString = Left(strOrig,InStr(strOrig,"-")) ' Could also be: Mid(strOrig,"-"))