473,473 Members | 2,215 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

String check

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
2 1672
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: José Joye | last post by:
Hello, I was wondering if there is a method that exists to replace multi-spaces within a string with single-space. eg: "12 3 4 56" --> "12 3 4 56" I think this could be done by...
51
by: Alan | last post by:
hi all, I want to define a constant length string, say 4 then in a function at some time, I want to set the string to a constant value, say a below is my code but it fails what is the correct...
32
by: tshad | last post by:
Can you do a search for more that one string in another string? Something like: someString.IndexOf("something1","something2","something3",0) or would you have to do something like: if...
8
by: Ken Wilson | last post by:
In spite of the obvious advantage of not encountering a NullReferenceException unexpectedly in your running program is there an offset cost in performance for using String.IsNullOrEmpty() over !=...
8
by: Ioannis Vranos | last post by:
In .NET (and C++/CLI) there is an overloaded String == operator for handles. That is when we do comparison of two String handles the contents of the Strings are compared instead of their addresses....
2
by: Badass Scotsman | last post by:
Hello, Using VB and ASP,NET I would like to be able to search a STRING for a smaller STRING within, based on the characters which appear before and after. For example: String1 = " That was...
6
by: tommaso.gastaldi | last post by:
Hi, does anybody know a speedy analog of IsNumeric() to check for strings/chars. I would like to check if an Object can be treated as a string before using a Cstr(), clearly avoiding the time...
2
by: FBergemann | last post by:
if i compile following sample: #include <iostream> #include <string> int main(int argc, char **argv) { std::string test = "hallo9811111z"; std::string::size_type ret;
9
by: a | last post by:
I need to write a regular expression to match a quoted string in which the double quote character itself is represented by 2 double quotes. For example: "beginning ""nested quoted string"" end"...
13
by: nishit.gupta | last post by:
Is their any fuction available in C++ that can determine that a string contains a numeric value. The value cabn be in hex, int, float. i.e. "1256" , "123.566" , "0xffff" Thnx
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.