Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

need help

COUNT occurrences
i need help i am makeing an program that will genrate an username form the fist and second name of the user useing the fist initial and the second name is there any code that i can use to count the varble ??
[235 byte] By [zero80472] at [2007-11-11 8:01:00]
# 1 Re: need help
you can try generating the username by getting the first name and second name and then processing it character by character?
jwala05 at 2007-11-11 17:26:04 >
# 2 Re: need help
but i need to know how to porcess each charter (sorry for my spelling )
zero80472 at 2007-11-11 17:27:04 >
# 3 Re: need help
Use VB's Left function to return the first character, and the Split function to split the username into first and last names.
Phil Weber at 2007-11-11 17:28:15 >
# 4 Re: need help
Hi.
ther are shorter methods, but this one is more obvious.
Supose..

txName= "Clark Nilo"
dim txFirst, txSecond, txResult as string
dim 2onPointer as integer
2ondPointer=instr(txName,chr(32))' if separator is different, change chr(32) to chr(..)
txResult=left(txName,1) & right(txName,2ondPointer+1,len(txName)-2ondPointer)

>>>>>Result>>> "CNILO"
MascaLineas at 2007-11-11 17:29:10 >
# 5 Re: need help
Or, to use the methods Phil suggested...

Dim txName as string
dim sSplit() as string
dim sUserID as string

txName = "Phil Weber"
sSplit = split(txname, " ")
sUserID = left$(ssplit(0)) & ssplit(1)

'sUserID now contains "PWeber"

BW, MascalLineas, you have a couple of variants in your code.

dim txFirst, txSecond, txResult as string

returns txFirst and txSecond as a variant, and txResult as a string.

If you want all three to be strings, you need to do this:

dim txFirst as string, txSecond as string, txResult as string
edburdo at 2007-11-11 17:30:08 >
# 6 Re: need help
Hi Edburdo.
I have "one line method" working only with the initial string, but..
I'v tryed to explain it, "line by line" , and "variable to variable" with simple methods.

Thanks.
MascaLineas at 2007-11-11 17:31:18 >
# 7 Re: need help
No problem... I could write up a one liner too... but it's easier to explain (as you pointed out) in pieces.

I was just making you aware of the fact that declaring multiple variables on one line requires you to type EACH VARIABLE, or they end up as variants (and variants are evil :) )
edburdo at 2007-11-11 17:32:18 >
# 8 Re: need help
Hy Edburdo. Ok.
I have only one doubt about it.

Has it been usefull for Zero80472?
I do'nt know.
In my country, No news..Good news! but...
Till soon.
MascaLineas at 2007-11-11 17:33:11 >