>>I am trying to remove the letter X from a string that sometimes will appear in a text box. I am programming an automation app for a factory that sometimes has the letter X at the end of a part number. I want to strip the X off before I evaluate the part number to a database.
>>
>>Here is what I have tried. However, the result is only the letter X, which is what I want to get rid of. Any suggestions for this...?
>>
>>Thanks in advance.
>>
>>Private Sub Command1_Click()
>>Dim xnum As String
>>Dim mylen As Single
>>Dim Newlen As Single
>>Dim min1 As Single
>>Dim NewPnum As String
>>
>>min1 = -1
>>xnum = Right(Text1.Text, 1)
>> If xnum = "X" Then
>> mylen = Len(xnum)
>> Newlen = mylen - min1
>> NewPnum = Left(xnum, Newlen)
>> Text1.Text = NewPnum
>> End If
>>
>>End Sub
>
>Or, you can try:
>
>Text1.Text = Replace(Text1.Text, "X", "")
>
>Which will replace all ocurrences of "X" with an empty string, effectively removing it.
>
>Now, it will not work for you if your part numbers also contain the letter "X" as part of a valid item number.
Thanks for the information. Yes some of the part numbers do contain the letter
"X", so it has to evaluate the last character in the string. I was able to fix
the problem with the code that I posted earlier and it is working well.
Thanks again for the input.
Brad
He is there and He is not Silent.