no1d
03-10-2003, 09:27 PM
ok i made a program that takes a first and last name and a birthday and creates a certain userid and password from it...so far it works if there is only 1 space between first and last name but its supposed to be able to do the same thing if there is 1 or more space between the names, if there is more then 1 space it throws off all the mid and left stuff that selects what letters of the inputed first and last name to use to make the userid/password... how can i make it work with more then 1 space? this is what i got so far:
Private Sub CmdCompute_Click()
Dim password As String
Dim user As String
Dim strname As String
Dim n As String
Dim dblp1 As Double
Dim dblp2 As Double
Dim dblp3 As Double
Dim dblp4 As Double
Dim dblBday As Double
'defining variables
dblBday = CDbl(TxtBirth.Text)
n = Trim(TxtName.Text)
strname = InStr(n, " ")
p1 = CDbl(Left(dblBday, 1)) + CDbl(Mid(dblBday, 2, 1))
p2 = CDbl(Mid(dblBday, 3, 1)) + CDbl(Mid(dblBday, 4, 1))
p3 = CDbl(Mid(dblBday, 7, 1))
p4 = CDbl(Right(dblBday, 1))
'creating userid and password
user = UCase(Mid(n, strname + 1, 2)) + UCase(Mid(n, strname - 1, 1)) + UCase(Mid(n, strname - 2, 1))
password = LCase(Left(n, 1)) + Trim(p1 + p2) + LCase(Mid(n, strname + 1, 1)) + Trim(p3 + p4)
'printing results
picPass.Cls
picPass.Print password
picId.Cls
picId.Print user
End Sub
Private Sub CmdCompute_Click()
Dim password As String
Dim user As String
Dim strname As String
Dim n As String
Dim dblp1 As Double
Dim dblp2 As Double
Dim dblp3 As Double
Dim dblp4 As Double
Dim dblBday As Double
'defining variables
dblBday = CDbl(TxtBirth.Text)
n = Trim(TxtName.Text)
strname = InStr(n, " ")
p1 = CDbl(Left(dblBday, 1)) + CDbl(Mid(dblBday, 2, 1))
p2 = CDbl(Mid(dblBday, 3, 1)) + CDbl(Mid(dblBday, 4, 1))
p3 = CDbl(Mid(dblBday, 7, 1))
p4 = CDbl(Right(dblBday, 1))
'creating userid and password
user = UCase(Mid(n, strname + 1, 2)) + UCase(Mid(n, strname - 1, 1)) + UCase(Mid(n, strname - 2, 1))
password = LCase(Left(n, 1)) + Trim(p1 + p2) + LCase(Mid(n, strname + 1, 1)) + Trim(p3 + p4)
'printing results
picPass.Cls
picPass.Print password
picId.Cls
picId.Print user
End Sub