how do i get rid of unwanted charaters in a variable?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

i'm trying to get rid of the underscore at the end of this string. I'm trying to count only the numeric characters.Any ideas???? HELP

Here is the code i have


FILE_NUMBER.Text = "123._____

Temp_File_Number = FILE_NUMBER.Tex
Temp_File_Number = LTrim(RTrim(Temp_File_Number)
FileNumLen = Len(Temp_File_Number


Any ideas???????
 
You could use:

Left(FILE_NUMBER, InStr(FILE_NUMBER, ".") -1)

This will return all characters to the left of the dot or . found in the
string.

--

Cheryl Fischer, MVP Microsoft Access
Law/Sys Associates, Houston, TX


Luis said:
i'm trying to get rid of the underscore at the end of this string. I'm
trying to count only the numeric characters.Any ideas???? HELP!
 
This function would allow you to return the length of a
given string starting from the beginning of the string to
the given delimiter, which in this case is an underscore.
Using the Trim function is only going to return the
string without spaces.
I hope this is what you were trying to do.
................
Function TextLengthToDelimiter(strInput As String,
strDelimiter As String) As Integer
On Error GoTo HandleError
Dim lngDelimStart As Long

TextLengthToDelimiter = InStr(1, strInput, strDelimiter) -
1

ExitHere:
Exit Function
HandleError:
msgbox Err.Description
Resume ExitHere
End Function
....................
-----Original Message-----
i'm trying to get rid of the underscore at the end of
this string. I'm trying to count only the numeric
characters.Any ideas???? HELP!
 
i'm trying to get rid of the underscore at the end of this string.
I'm trying to count only the numeric characters.Any ideas???? HELP!


Here is the code i have:

{ FILE_NUMBER.Text = "123._____"

Temp_File_Number = FILE_NUMBER.Text Temp_File_Number =
LTrim(RTrim(Temp_File_Number)) FileNumLen = Len(Temp_File_Number) }


Any ideas???????

What about the dot?

Temp_File_ Number =
Left([Temp_File_Number],Instr([Temp_File_Number],"_")-1)
123.

An even easier way if you don't need the dot:
Temp_File_Number = Val([Temp_File_Number])
123
 
i'm trying to get rid of the underscore at the end of this string. I'm trying to count only the numeric characters.Any ideas???? HELP!

Here is the code i have:

{
FILE_NUMBER.Text = "123._____"

Temp_File_Number = FILE_NUMBER.Text
Temp_File_Number = LTrim(RTrim(Temp_File_Number))
FileNumLen = Len(Temp_File_Number)
}

Any ideas???????

Ummm... { } suggests to me that you're writing in a dialect of C. This
newsgroup is for Microsoft Access, for which the usual language is
VBA. Are you in fact using VBA? What's the context?

A VBA solution would be

Len(Replace(Temp_File_Number, "_", ""))

but this would return 4 for the four-character string "123."
 
Back
Top