473,545 Members | 1,890 Online
Bytes | Software Development & Data Engineering Community
+ 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 1682
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.

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(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.


Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5061
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 looking at each char within a loop and copying the char to a stringBuilder instance if current and previous char are not spaces...
51
8225
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 code? many thx!
32
14769
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 ((someString.IndexOf("something1",0) >= 0) || ((someString.IndexOf("something2",0) >= 0) ||
8
7365
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 != ""? If so, would it be of any great significance if a large number of strings were being tested over the run of an application? Ken Wilson...
8
2295
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. However how can we do a handle comparison when we want to determine if we have to do with the same object? In the style
2
3165
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 a tasty burger"
6
2197
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 and resource consuming Try... Catch, which in iterative processing is totally unacceptable. -tom
2
5480
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
7340
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" Any idea how to write this in boost::xpressive or boost::regex. Thanks,
13
14951
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
7478
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7410
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7437
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7773
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
4960
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3466
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3448
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1901
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 we have to send another system
0
722
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.