Solved

Special characters should not be allowed in single line edit control

Posted on 2007-03-29
1
437 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
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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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 perform CRUD operations on a MySql database.
The viewer will learn how to use and create new code templates in NetBeans IDE 8.0 for Windows.

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now