删除字符串的第一个字符,如果它等于某个字符串

Asy*_*ous 13 vba access-vba

我正在为Access 2010练习VBA.

我阅读了有关我的帖子的所有建议帖子,但没有找到任何具体的内容.我知道如何在字符串中移动特定字符,我不知道的是我如何删除等于某事物的特定字符.

我想从电话号码移动角色1或1-,如果有的话.

示例:17188888888至7188888888或1-7188888888至7188888888

我试图使用一个if语句,首先只删除1.

电话号码输入为字符串而不是数字.

这就是我开始的:我收到一条错误消息,表明RemoveFirstChar是不明确的.

Public Function RemoveFirstChar(RemFstChar As String) As String
If Left(RemFstChar, 1) = "1" Then
  RemFstChar = Replace(RemFstChar, "1", "")
End If
RemoveFirstChar = RemFstChar
End Function
Run Code Online (Sandbox Code Playgroud)

Kar*_*rel 21

我已经在Access 2010中测试了你的功能,它只是有效..你也可以使用这段代码:

Public Function RemoveFirstChar(RemFstChar As String) As String
Dim TempString As String
TempString = RemFstChar
If Left(RemFstChar, 1) = "1" Then
    If Len(RemFstChar) > 1 Then
        TempString = Right(RemFstChar, Len(RemFstChar) - 1)
    End If
End If
RemoveFirstChar = TempString
End Function
Run Code Online (Sandbox Code Playgroud)