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(B yVal validchars As String, _
ByVal userinput As String) As Boolean
Dim c As Char
For Each c In userinput
If validchars.Inde xOf(c) < 0 Then
Return False
End If
Next
Return True
End Function
Private Sub OpenDatabase()
Dim vChars As String = _
"ABCDEFGHIJKLMN OPQRSTUVWXYZabc defghijklmnopqr stuvwxyz*&%$#!"
Dim userid As String
Dim password As String
If ValidateInput(v Chars, UserName.Text) Then
userid = UserName.Text
Else
Throw New System.Exceptio n("Invalid user name.")
End If
If ValidateInput(v Chars, PasswordText.Te xt) Then
password = PasswordText.Te xt
Else
Throw New System.Exceptio n("Invalid password.")
End If
Dim connectionStrin g As String
connectionStrin g = "data source=myserver "
connectionStrin g &= ";initial catalog=northwi nd"
connectionStrin g &= ";user id=" & userid
connectionStrin g &= ";password= " & password
SqlConnection1. ConnectionStrin g = connectionStrin g
SqlConnection1. Open()
' Further code to work with the database
End Sub
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:uW******** ******@TK2MSFTN GP14.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.Enc oding = _
System.Text.Enc oding.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.