?
Solved

Special characters should not be allowed in single line edit control

Posted on 2007-03-29
1
Medium Priority
?
445 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 200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Programmer's Notepad is, one of the best free text editing tools available, simply because the developers appear to have second-guessed every weird problem or issue a programmer is likely to run into. One of these problems is selecting and deleti…
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: …
The viewer will learn how to use NetBeans IDE 8.0 for Windows to connect to a MySQL database. Open Services Panel: Create a new connection using New Connection Wizard: Create a test database called eetutorial: Create a new test tabel called ee…
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses

801 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