Q:Replacing "letters" with "******"

Q: How to replace any characters with asterisk (*)?

Page 1 of 1

5 Replies - 4994 Views - Last Post: 24 April 2008 - 02:35 PM Rate Topic: -----

#1 mark25  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 15-April 08

Q:Replacing "letters" with "******"

Posted 22 April 2008 - 03:13 PM

Please help if you know on how to replace text with different charactes when typing in a field? Some password stuffs. Like, I want to replace this word "leads" to "*****" but still the program reads that as "leads"

I've made a simple program and it works. I made 3 forms and it works perfectly. Problem is that i just want to replace every character with "asterisk" (*) but reads the same.

Private Sub Command1_Click()
If Text1 = "leads" Then
Form2.Show 1, Me
Exit Sub
End If
If Text1 = "farmerman" Then
Form3.Show 1, Me
Exit Sub
End If
If Text1 <> "leads" Then
MsgBox "Enter valid User type!", vbInformation, "User Info"
Text1.SetFocus
Exit Sub
End If
End Sub


Is This A Good Question/Topic? 0
  • +

Replies To: Q:Replacing "letters" with "******"

#2 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4421
  • View blog
  • Posts: 12,286
  • Joined: 18-April 07

Re: Q:Replacing "letters" with "******"

Posted 22 April 2008 - 03:41 PM

If you mean use asterisks only in place of the password within the code, no you can't do that. Actually the idea of hardcoding passwords into a problem to begin with. What if the user wants to change passwords or you want to provide them the ability to change the password later? You are forced to change and recompile the program.

Now you can do it for display to the user by using the String(number,character) function and for "number" you would use the length of the string. So you should be able to do for "hello" String(len("hello"),"*").

What most people do for passwords though is hash the password and store it somewhere (like in a database or a file) and then when the user logs in and provides a password, you hash what they give you (using a hash function like an MD5 algorithm) and compare the two hashes to see if they match. That way no one can read the hashed password, but the user can use their password to verify their identity.

You can find such an MD5 algorithm at the URL...

MD5 Hash for VB and other languages

Enjoy! :)
Was This Post Helpful? 0
  • +
  • -

#3 anand_the_great  Icon User is offline

  • New D.I.C Head

Reputation: 2
  • View blog
  • Posts: 47
  • Joined: 15-April 08

Re: Q:Replacing "letters" with "******"

Posted 23 April 2008 - 05:50 PM

mark25 do you mean to say that it is like a "password" thing.

User_ID: 12345
Password:*****

If that is the case, this is easy, in fact it requires no programming.

I assume that you are using the Text1(TextBox) as input to get the password.

Simply, click on Text1 --> go to properties on window.

Now, look in PasswordChar. Enter only once the * thing.

Like this PasswordCar| * .

Take care and please reply to me. Thanks.

Anand.
Was This Post Helpful? 1
  • +
  • -

#4 Virus Lover  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 12
  • Joined: 16-April 08

Re: Q:Replacing "letters" with "******"

Posted 23 April 2008 - 11:37 PM

'anand_the_great' you are right its easy to do that jsut change passworchar and put *


thats easy

This post has been edited by Virus Lover: 23 April 2008 - 11:38 PM

Was This Post Helpful? 1
  • +
  • -

#5 mark25  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 15-April 08

Re: Q:Replacing "letters" with "******"

Posted 24 April 2008 - 10:16 AM

View PostVirus Lover, on 23 Apr, 2008 - 11:37 PM, said:

'anand_the_great' you are right its easy to do that jsut change passworchar and put *


thats easy



sweet! that's effortless man! thank you! that's exactly what i was looking for hahaha! thanks!


to martyr,

thanks for the link! it helps too!
Was This Post Helpful? 0
  • +
  • -

#6 benpap  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 6
  • View blog
  • Posts: 51
  • Joined: 24-November 07

Re: Q:Replacing "letters" with "******"

Posted 24 April 2008 - 02:35 PM

View PostMartyr2, on 22 Apr, 2008 - 03:41 PM, said:

If you mean use asterisks only in place of the password within the code, no you can't do that. Actually the idea of hardcoding passwords into a problem to begin with. What if the user wants to change passwords or you want to provide them the ability to change the password later? You are forced to change and recompile the program.

Now you can do it for display to the user by using the String(number,character) function and for "number" you would use the length of the string. So you should be able to do for "hello" String(len("hello"),"*").

What most people do for passwords though is hash the password and store it somewhere (like in a database or a file) and then when the user logs in and provides a password, you hash what they give you (using a hash function like an MD5 algorithm) and compare the two hashes to see if they match. That way no one can read the hashed password, but the user can use their password to verify their identity.

You can find such an MD5 algorithm at the URL...

MD5 Hash for VB and other languages

Enjoy! :)


thanks for that one!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1