Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help On Password Program
Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
ParanoidBacon




PostPosted: Sat Mar 15, 2008 1:50 pm   Post subject: Help On Password Program

I'm trying to go through the projects in my VB 6.0 Textbook as fast as i can but i ran into a little snag. The program essentially just have you input name, password and date and the output would display what you entered in each field. My dilemma is on the password part. I don't remember reading anything about this within the chapter but what I am supposed to do is...

"As characters are typed into the second text box[the field for the password], the key press event should be used to capture the character typed, store it in an invisible label, and replace it in the text box with an asterisk".

Thats basically what i need help with, i made the text box a key press event and a made an additional label and I'm not sure how to progress from here.
Sponsor
Sponsor
Sponsor
sponsor
ParanoidBacon




PostPosted: Sat Mar 15, 2008 2:34 pm   Post subject: RE:Help On Password Program

Option Explicit

Private Sub cmdOut_Click()
Dim day As String, strDate As String, strName As String, n As Integer, m As Integer, first As String, last As String

strName = txtName.Text
m = InStr(strName, ",")
first = Right(strName, m - 1)
last = Left(strName, m - 1)
picOut.Print "Your name Is "; first; " "; last

picOut.Print "Your Password is "; txtPass.Text

strDate = FormatDateTime(txtDate.Text, vbLongDate)
n = InStr(strDate, ",")
day = Left(strDate, n - 1)
picOut.Print "You were born on a "; day; "."
End Sub

Private Sub cmdOut_KeyPress(KeyAscii As Integer)

End Sub
ParanoidBacon




PostPosted: Sat Mar 15, 2008 2:40 pm   Post subject: Re: Help On Password Program

Posted Image, might have been reduced in size. Click Image to view fullscreen.

Posted my code and the program in runtime with everything else except the password portion, just to see if this would help your guys help me
Dan




PostPosted: Sat Mar 15, 2008 2:45 pm   Post subject: RE:Help On Password Program

If i rember right VB has a password text field that will do this for you, or at least there is an option for text fileds to replace all chars with the char of your choice.

However if you have to use the method desribled above the process would be to check for a key press, then if and only if the password filed is in fouces add the char pressed into a hidden field and add a '*' char to the acutal password field. If backspace is hit, and if and only if the password field is in fouces remove the last char from the hidden field and the last '*' from the password field.

Unfrontly i am not very fimualr with VB syntext so some one else will have to help you with the aucatal coding if you need more help.
Computer Science Canada Help with programming in C, C++, Java, PHP, Ruby, Turing, VB and more!
nike52




PostPosted: Sat Mar 15, 2008 2:49 pm   Post subject: Re: Help On Password Program

Private Sub Text2_KeyPress(KeyAscii As Integer)
Label6.Caption = Label6.Caption + "*"
End Sub

You wanna do this right?
Every time they press a key it'll add a *

I'm guessing they're storing the char as an Ascii, you how every key like "a" is represented by a number.
You simply got to convert the int to Ascii, check out Ascii in your textbook somewhere and you should be good to go:).
ParanoidBacon




PostPosted: Sun Mar 16, 2008 8:30 pm   Post subject: Re: Help On Password Program

Fixed....my problem was that i was stuck on the "keypress Event" part, but i don't think that is what i was supposed to do, it works fine without making a keypress Event. Heres the code for those that are interested.


Option Explicit

Private Sub cmdOut_Click()
Dim day As String, strDate As String, l As Integer, strName As String, n As Integer, m As Integer, first As String, last As String

strName = txtName.Text
l = Len(strName) - 1
m = InStr(strName, ",")
first = Right(strName, l - m)
last = Left(strName, m - 1)
picOut.Print "Your name Is "; first; " "; last

picOut.Print "Your Password is "; lblhid.Caption

strDate = FormatDateTime(txtDate.Text, vbLongDate)
n = InStr(strDate, ",")
day = Left(strDate, n - 1)
picOut.Print "You were born on a "; day; "."
End Sub


Private Sub txtPass_Change()
Dim password As String
password = txtPass.Text
txtPass.Text = "" + txtPass.Text
txtPass.PasswordChar = "*"
lblhid.Caption = password
End Sub
MysticVegeta




PostPosted: Tue Apr 01, 2008 6:25 pm   Post subject: RE:Help On Password Program

I think this whole question is stupid. Why recreate something that already exists? The password char property already exists, so its stupid. Anyways, but thats me. I think a better way to train for the keypress event would be making some sort of a graphical ball move or something
Display posts from previous:   
   Index -> Programming, Visual Basic and Other Basics -> Visual Basic Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 7 Posts ]
Jump to:   


Style:  
Search: