删除字符串的第一个字符(如果等于) [英] Removing the first character of a string if it equals something
问题描述
我正在为Access 2010练习VBA。
I am practicing VBA for Access 2010.
我阅读了所有有关我的帖子的建议帖子,但没有发现任何具体内容。
我知道如何在字符串中移动特定字符,但我不知道如何删除等于某字符的特定字符。
I read all the suggested post regarding my post but did not find anything specific. I know how to move specific characters in a string, what I do not know is how I can remove specific character that equals to something.
我想将电话中的字符1或1移到电话号码中。
I want to move the character 1 or 1- from telephone numbers if one is there.
例如:17188888888至7188888888或1-7188888888至7188888888
Example: 17188888888 to 7188888888 or 1-7188888888 to 7188888888
我正在尝试使用if语句,首先删除1。
I am trying to use an if statement starting first with just removing the 1.
电话号码是字符串而不是数字。
The phone number is entered as a string not numbers.
这就是我开始的内容:我收到一条错误消息,提示 RemoveFirstChar 含糊。
This is what I have started: I am getting an error message that RemoveFirstChar is ambiguous.
Public Function RemoveFirstChar(RemFstChar As String) As String
If Left(RemFstChar, 1) = "1" Then
RemFstChar = Replace(RemFstChar, "1", "")
End If
RemoveFirstChar = RemFstChar
End Function
推荐答案
我已经在Access 2010中测试了您的功能,但它只是起作用。.您也可以使用此c ode:
I have tested your function in Access 2010 and it worked just fune.. You can also use this code:
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
这篇关于删除字符串的第一个字符(如果等于)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!