return 表达式 "end of statement expected" 中的 VB6 函数问题
VB6 function issue in the return expression "end of statement expected"
我是 vb6 的新手,在尝试 return 我的变量时我的函数出现编译器错误。
"end of statement expected error vb6"
我的函数如下:
Public Function StringFormat(ByVal MyStr As String) As String
Dim i As Integer
Dim sBadChar As String
Dim NewString As String
' List all illegal/unwanted characters
sBadChar = "/<>?\{}[]()=,!#*:'*¬-"
' Loop through all the characters of the string
For i = 1 To Len(MyStr)
If InStr(sBadChar, Mid(MyStr, i, 1)) Then
Mid(MyStr, i, 1) = ""
End If
Next i
Return MyStr
End Function
我在 return
上收到错误,关于为什么会发生这种情况的任何想法?
提前谢谢你
应该是:
Public Function StringFormat(ByVal MyStr As String) As String
Dim i As Integer
Dim sBadChar As String
Dim NewString As String
' List all illegal/unwanted characters
sBadChar = "/<>?\{}[]()=,!#*:'*¬-"
' Loop through all the characters of the string
For i = 1 To Len(MyStr)
If InStr(sBadChar, Mid(MyStr, i, 1)) Then
Mid(MyStr, i, 1) = ""
End If
Next i
StringFormat = MyStr
End Function
我是 vb6 的新手,在尝试 return 我的变量时我的函数出现编译器错误。
"end of statement expected error vb6"
我的函数如下:
Public Function StringFormat(ByVal MyStr As String) As String
Dim i As Integer
Dim sBadChar As String
Dim NewString As String
' List all illegal/unwanted characters
sBadChar = "/<>?\{}[]()=,!#*:'*¬-"
' Loop through all the characters of the string
For i = 1 To Len(MyStr)
If InStr(sBadChar, Mid(MyStr, i, 1)) Then
Mid(MyStr, i, 1) = ""
End If
Next i
Return MyStr
End Function
我在 return
上收到错误,关于为什么会发生这种情况的任何想法?
提前谢谢你
应该是:
Public Function StringFormat(ByVal MyStr As String) As String
Dim i As Integer
Dim sBadChar As String
Dim NewString As String
' List all illegal/unwanted characters
sBadChar = "/<>?\{}[]()=,!#*:'*¬-"
' Loop through all the characters of the string
For i = 1 To Len(MyStr)
If InStr(sBadChar, Mid(MyStr, i, 1)) Then
Mid(MyStr, i, 1) = ""
End If
Next i
StringFormat = MyStr
End Function