trim - a string with variating length

kirstyb

Member
Joined
Sep 12, 2005
Messages
7
Programming Experience
Beginner
RESOLVED: trim - a string with variating length

Hi guys,

I'm doing an application at the mo that consolidates files together.

sick.gif
The bit I'm stuck on involves the user specifying a file format options can be:

123_worldwide_uk_csb
3565_worldwide_nl_icsb
32_worldwide_uk_arbor
32_worldwide_web_uk_csb (The application populates a combobox from a dll file)

The combobox populates fine, displaying about 20 of the above file types for the user to choose from.

What I need is the code to return only the characters after the final underscore so:

csb
icsb
or arbor depending on which the user selects

As you can see the amount of underscores may change, the length of the string will change and the length of the file type used by the application also changes.

HOW TO I GET RID OF EVERYTHING UP TO AND INCLUDING THE FINAL UNDERSCORE????

Thanks guys
 
Last edited:
you could always check each one and work backwards through the string and only keep everything from the end to the first underscore
 
string aa = "123_worldwide_uk_csb"
dim sSplit(50) as string

if Instr(aa,"-") then
sSplit = split(aa, "_")
end if

MsgBox(sSplit(UBound(sSplit))

will give word after last underscore
 
Deepthiv said:
string aa = "123_worldwide_uk_csb"
dim sSplit(50) as string

if Instr(aa,"-") then
sSplit = split(aa, "_")
end if

MsgBox(sSplit(UBound(sSplit))

will give word after last underscore

thanks for that!!!!
 
Back
Top