I need the code for how to make a app for the following..
To make a name typed into a textbox and display only the initials, and capitalize them. How in the world do I do this... :confused:
Vb code only plz tkx :thumbup:
I am little rusty but here it is:
txt_Name is the name text box, Txt_INitials is the result initials
Private Sub GO_Click()
? ?Dim sName
? ?Dim sInitials
? ?Dim integerCharCount 'Thanks to ian :)
? ?
? ?sInitials = ""
? ?sName = Txt_Name.Text
? ?
? ?'---- If there is any text, take first letter ----
? ?
? ?If Len(sName) > 0Then
? ? ? ?sInitials = Left(sName, 1)
? ?End If
? ? ? ?
? ?'---- Loop through name and take letters after a space --
? ?
? ?integerCharCount = 2
? ?
? ?Do While integerCharCount < Len(sName)
? ? ? ?If Mid(sName, integerCharCount - 1, 1) = " " And Mid(sName, integerCharCount, 1) <> " " Then
? ? ? ? ? ?sInitials = sInitials + Mid(sName, integerCharCount, 1)
? ? ? ?End If
? ?Loop
? ? ? ?
? ?Txt_Initials.Text = sInitials
? ? ? ?
End Sub
why did you use such awful variables ?:confused: ?:tongue:
if you mean sName and sInitials, I use hungarian notation whenever I can, which means the first character(s) of the variable tell you what type it is.
s is for String.
If you mean txt_Name, txt is to show it is a text box.
I code in a few languages and use different standards, I haven't used VB for a while.
I think they are meaningful, they tell me what type of variable they are, and the names tell me what they are.
What would you have used???
hehe, that arent bad if you know what they mean... now that i know what i mean, they arent so bad... but i wouldve written them out like stringName, or inputtedText, just something that any idiot (such as i) could understand without having to go through all the code and figure out what was being used for what. the one that got me the most was this, "ia". I'm assuming its a counter, but ack! :D
anyway, it works well, so it doesn't matter. :)
hehe, that arent bad if you know what they mean... now that i know what i mean, they arent so bad... but i wouldve written them out like stringName, or inputtedText, just something that any idiot (such as i) could understand without having to go through all the code and figure out what was being used for what. the one that got me the most was this, "ia". I'm assuming its a counter, but ack! ?:D
anyway, it works well, so it doesn't matter. ?:)
yeah ia is a bad habit I picked up from my C days.
It is suppose to mean i as in integer, the a is because I use a lot of temporary counters and call them ia, ib, ic.
Yeah I agree that is shit, it should have been iCharCount or something like that.
I have a lot of bad habits, because most of what i know with languages is self taught.
What are they teaching schools these days? stringName is good, in C++ they recommend szName, where sz stands for "null terminated string".
Ahh well, the harder my code is to read, the more times they have to call me back to modify it hehe "I AM IRREPLACEABLE"
lol
/me modifies code
:eek:
heh, well in the java class im taking, the professor stressed using variables involving a full name to show what it really does, and the same goes for functions, or methods, whatever you want to call them...
names such as getActionWindow, real words to help remember what its for... but thats java, and java sucks anus. :thumbdown: