Solved

Special characters should not be allowed in single line edit control

Posted on 2007-03-29
1
441 Views
Last Modified: 2013-12-26
I have a single line edit control in my window. The requirement is user should not be allowed to enter special characters in that single line edit. That means only it should accept alpha numeric characters.

Can any one give generic code for this?

Thanks
Srinib
0
Comment
Question by:srinib
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 14

Accepted Solution

by:
sandeep_patel earned 50 total points
ID: 18821832
hi,

create a global or local funtion with name uf_isalphanum(string as_string) returns boolean

///script
long ll_count=0
long ll_length
char lc_char[]
integer      li_ascii
boolean lb_null

If IsNull(as_string) Then
      SetNull(lb_null)
      Return lb_null
End If

ll_length = Len (as_string)

If ll_length=0 Then
      Return False
End If

lc_char = as_string

do while ll_count<ll_length
      ll_count ++
      li_ascii = Asc (lc_char[ll_count])
      
      // '0'= 48, '9'=57, 'A'=65, 'Z'=90, 'a'=97, 'z'=122
      If li_ascii<48 or (li_ascii>57 and li_ascii<65) or &
            (li_ascii>90 and li_ascii<97) or li_ascii>122 then
            Return False
      end if
loop

return True

now you can call this function anywhere... and check return value

Regards,
Sandeep
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here is a helpful source code for C++ Builder programmers that allows you to manage and manipulate HTML content from C++ code, while also handling HTML events like onclick, onmouseover, ... Some objects defined and used in this source include: …
How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand columnThat will then direct you to their download page.From that page s…
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question