我是 vb6 的新手,当尝试返回变量时,我的函数中出现编译器错误。
\n\n\n“语句结束预期错误vb6”
\n
我的功能如下:
\nPublic Function StringFormat(ByVal MyStr As String) As String\n \n Dim i As Integer\n Dim sBadChar As String\n Dim NewString As String\n \n ' List all illegal/unwanted characters\n sBadChar = "/<>?\\{}[]()=,!#*:'*\xc2\xac-"\n\n ' Loop through all the characters of the string\n For i = 1 To Len(MyStr)\n If InStr(sBadChar, Mid(MyStr, i, 1)) Then\n Mid(MyStr, i, 1) = ""\n End If\n Next i\n \n Return MyStr\n \nEnd Function\nRun Code Online (Sandbox Code Playgroud)\n我收到错误return,关于为什么会发生这种情况有什么想法吗?\n提前谢谢您
小智 5
应该:
\nPublic Function StringFormat(ByVal MyStr As String) As String\n \n Dim i As Integer\n Dim sBadChar As String\n Dim NewString As String\n \n ' List all illegal/unwanted characters\n sBadChar = "/<>?\\{}[]()=,!#*:'*\xc2\xac-"\n\n ' Loop through all the characters of the string\n\n For i = 1 To Len(MyStr)\n If InStr(sBadChar, Mid(MyStr, i, 1)) Then\n Mid(MyStr, i, 1) = ""\n End If\n Next i\n \n StringFormat = MyStr \n \n End Function\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
215 次 |
| 最近记录: |