Welcome to Dream.In.Code
Getting VB Help is Easy!

Join 86,392 VB Programmers. There are 1,413 online right now! Ask your question and get quick answers from Dream.In.Code experts. Join the #1 programming help community on the internet! Registration is fast and FREE... Join Now!

Chat LIVE With a VB Expert
Powered by LivePerson.com

Register to Make This Box Go Away!

String Function Help

 
Reply to this topicStart new topic

String Function Help, Multlple functions

gtoman69
post 7 May, 2008 - 05:50 PM
Post #1


New D.I.C Head

*
Joined: 7 May, 2008
Posts: 2



I need to pull multiple characters and display them all together to create a password.

ex. First name Bob
Last name Smith
Phone number 123-4567
I need it to look like 321smib this is what I have

'Create the Password from the textboxes
lblPassword.Caption = Right(txtFirstName, 1)

lblPassword.Caption = Left(txtLastName.Text, 3)
but this only gives me the Last name
User is offlineProfile CardPM
Go to the top of the page
+Quote Post


Zhalix
post 7 May, 2008 - 07:11 PM
Post #2


New D.I.C Head

*
Joined: 7 May, 2008
Posts: 37

I know why it's only giving you the bit from the last name. Take a close look at the two lines:

CODE

lblPassword.Caption = Right(txtFirstName, 1)
lblPassword.Caption = Left(txtLastName.Text, 3)


The first line is fine, but the second line is where it goes wrong. You're overwriting the information you got from the first name with the information you're getting from the last name.

To fix it, just write this instead:

CODE

lblPassword.Caption = Right(txtFirstName.Text, 1)
lblPassword.Caption = lblPassword.Caption & Left(txtLastName.Text, 3)


By doing so, you're preserving the original value and adding onto it.

This post has been edited by Zhalix: 7 May, 2008 - 07:48 PM
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

sam_benne
post 7 May, 2008 - 11:49 PM
Post #3


D.I.C Head

Group Icon
Joined: 16 Jan, 2008
Posts: 148

If I was doing this then i would do this:
CODE

First = Mid(txtFirstName.Text, 1, 1)
Second = Mid(txtLastName.Text, 1, 3)

lblPassword.caption = First + Second

User is offlineProfile CardPM
Go to the top of the page
+Quote Post

diehardredsoxfan3
post 8 May, 2008 - 05:24 PM
Post #4


New D.I.C Head

*
Joined: 12 Feb, 2008
Posts: 5

do you still need to get the numbers part?
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 5/17/08 05:10AM

Live VB Help!

VB Tutorials

Reference Sheets

VB Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month