By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,238 Members | 1,196 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,238 IT Pros & Developers. It's quick & easy.

String check

P: n/a
I have an app with text boxes used to change user password
Textbox1 - old password
Textbox2 - new password
Textbox3 - new password second time

What I need is how to check if the newely created password is with standart
ascii symbols. Maybe I am not describing it well, but I don't know the exact
term.

What I wont to achieve is, that the should not type password in our local
language (Bulgarian), but only in English. Because the textboxes accept
everything in Unicode I don't know how to check if textbox text is in
specific language set.

Maybe I should make a custom control, inherited from the Textbox control,
which will implement this feature, but for now I need the knowledge how to
achieve my current goal.

Any help will be greatly appreciated.
Nov 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Nikolay,

I don't know if there is a better way, however this was where I was thinking
about

\\\
Dim ascii As System.text.Encoding = _
System.Text.Encoding.ASCII
Dim a As String = "Hello I am here"
Dim b As String = "??"
If a = ascii.GetString(ascii.GetBytes(a)) _
Then MessageBox.Show("I am correct")
If b <> ascii.GetString(ascii.GetBytes(b)) _
Then MessageBox.Show("I am not correct")
///

I hope this helps?

Cor

"Nikolay Petrov" <jo**************@mail.bg>
I have an app with text boxes used to change user password
Textbox1 - old password
Textbox2 - new password
Textbox3 - new password second time

What I need is how to check if the newely created password is with
standart ascii symbols. Maybe I am not describing it well, but I don't
know the exact term.

What I wont to achieve is, that the should not type password in our local
language (Bulgarian), but only in English. Because the textboxes accept
everything in Unicode I don't know how to check if textbox text is in
specific language set.

Maybe I should make a custom control, inherited from the Textbox control,
which will implement this feature, but for now I need the knowledge how to
achieve my current goal.

Any help will be greatly appreciated.

Nov 21 '05 #2

P: n/a
I've found a sample code in MSDN, which also could do the job.
It is used to dynamicaly creat SQL connection strings, but can be used in my
case also.
For anyone interested, here it is:

Private Function ValidateInput(ByVal validchars As String, _
ByVal userinput As String) As Boolean
Dim c As Char
For Each c In userinput
If validchars.IndexOf(c) < 0 Then
Return False
End If
Next
Return True
End Function

Private Sub OpenDatabase()
Dim vChars As String = _
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvw xyz*&%$#!"
Dim userid As String
Dim password As String
If ValidateInput(vChars, UserName.Text) Then
userid = UserName.Text
Else
Throw New System.Exception("Invalid user name.")
End If
If ValidateInput(vChars, PasswordText.Text) Then
password = PasswordText.Text
Else
Throw New System.Exception("Invalid password.")
End If
Dim connectionString As String
connectionString = "data source=myserver"
connectionString &= ";initial catalog=northwind"
connectionString &= ";user id=" & userid
connectionString &= ";password=" & password
SqlConnection1.ConnectionString = connectionString
SqlConnection1.Open()
' Further code to work with the database
End Sub

"Cor Ligthert" <no************@planet.nl> wrote in message
news:uW**************@TK2MSFTNGP14.phx.gbl...
Nikolay,

I don't know if there is a better way, however this was where I was
thinking about

\\\
Dim ascii As System.text.Encoding = _
System.Text.Encoding.ASCII
Dim a As String = "Hello I am here"
Dim b As String = "??"
If a = ascii.GetString(ascii.GetBytes(a)) _
Then MessageBox.Show("I am correct")
If b <> ascii.GetString(ascii.GetBytes(b)) _
Then MessageBox.Show("I am not correct")
///

I hope this helps?

Cor

"Nikolay Petrov" <jo**************@mail.bg>
I have an app with text boxes used to change user password
Textbox1 - old password
Textbox2 - new password
Textbox3 - new password second time

What I need is how to check if the newely created password is with
standart ascii symbols. Maybe I am not describing it well, but I don't
know the exact term.

What I wont to achieve is, that the should not type password in our local
language (Bulgarian), but only in English. Because the textboxes accept
everything in Unicode I don't know how to check if textbox text is in
specific language set.

Maybe I should make a custom control, inherited from the Textbox control,
which will implement this feature, but for now I need the knowledge how
to achieve my current goal.

Any help will be greatly appreciated.


Nov 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.