Computer Science Canada VB 6.0 String Help |
Author: | EdwardNaru [ Sun Oct 28, 2007 6:21 pm ] |
Post subject: | VB 6.0 String Help |
Hey guys. Just asking for some string help..=] It'd be nice if you guys can help me out "Create a program which will ask the user to enter a first and last name in a single text box (separate the names with a space). Then at the click of a button the program will create and print three different logins. The first login is: the first 4 letters of the first name followed by the first 3 letters of the last name, the second login is: the last name (without the first letter) followed by the first letter of the first name and the thid login is:the first letter of your first name followed by the last 4 letters of your last name. For example the 3 logins are of "sandra johnston" are "SandJoh" and "ohnstonS" and "Sston".. I've tried many times and get it..if someone can point me in the right direction..please.xD |
Author: | Clayton [ Sun Oct 28, 2007 10:41 pm ] |
Post subject: | RE:VB 6.0 String Help |
Some example code would be good. It's hard to point you in the right direction if we don't even know what you have attempted so far. |
Author: | EdwardNaru [ Mon Oct 29, 2007 7:37 pm ] |
Post subject: | Re: VB 6.0 String Help |
Option Explicit Private Sub cmdcalc_Click() Dim strfirstlogin As String Dim strsecondlogin As String Dim strthirdlogin As String Dim strSpace As String Dim strfullName As String Dim strFirstName As String Dim strLastName As String strfullName = txtout.Text strSpace = InStr(strfullName, " ") strFirstName = strLastName = Right(strSpace) strfirstlogin = Left(strFirstName, 4) 'strfirstlogin = Mid(strfullName, strSpace + 4, 3) picanswer.Print strfirstlogin End Sub Private Sub Form_Load() End Sub VERY INCOMPLETE. I have no skill at strings. |
Author: | Brightguy [ Thu Nov 01, 2007 2:59 pm ] |
Post subject: | Re: VB 6.0 String Help |
First, make sure you know what the string functions (InStr, Left, Right, Mid, Len...) do. You can use InStr to find the position where the space is in the input string, so that then you know where the first/last names start and end. (VB6 also has a split function which will split a string into an array of substrings.) Once you have the first and last name, it's just a matter of selecting the right characters from them, as per specifications. |