DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 4 of 4

Thread: Need help about text box

  1. #1
    Join Date
    Aug 2004
    Posts
    43,023

    Need help about text box

    [Originally posted by Eli]

    Can someone tell me how can I make my program recognize every letter (and not just one letter)from the text box to avoid making many text boxes. Example: I have made a program for numerology and user must put his or her name, surname ecc. in the text boxex then program recognise every letter as a number (letter A is number 1, letter B is number 2 and so on)and write this value in other box. Now user must write every letter in a single text box and this is not useful so much. This is just an example to disribe what is the program about for better understanding. So I would like to know the code or some explanation how can I make just one box for name as example and one other for surname and the program can recognise every single letter and put this values in the other prepared boxes.

    Thanks
    Eli

  2. #2
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Need help about text box

    [Originally posted by Greg DeBacker]

    This may be what you need. The sub routine ChangeToNum() will convert a string to a number like you said (a = 1, b = 2, c = 3, etc.) Call it from the _Change() event of the TextBox and it will convert as the user types.

    Grex

    Private Sub Text1_Change()
    'Take the text typed in Text1
    'change it to numbers
    'and put it in Text2
    ChangeToNum Text1, Text2
    End Sub

    Private Sub ChangeToNum(TxtIn As TextBox, TxtOut As TextBox)
    Dim sTemp As String
    Dim sTemp2 As String
    Dim k As Integer
    sTemp = LCase$(TxtIn.Text)
    For k = 1 To Len(sTemp)
    sTemp2 = sTemp2 & Trim$(Str$(Asc(Mid$(sTemp, k, 1)) - 96))
    Next

    TxtOut.Text = sTemp2
    End Sub

  3. #3
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Need help about text box

    [Originally posted by Eli]

    Thank you for your help Grex, this realy works and it`s very useful, but there is one more problem. Everything is ok but i forgot to tell you that numbers are not exactly in this order. I will explain you in the following rows.
    a is 1
    b is 2
    c is 3
    d is 4
    e is 5
    f is 6
    g is 7
    h is 8
    i is 9
    j is 1
    k is 2
    l is 3
    m is 4
    n is 5
    o is 6
    p is 7
    q is 8
    r is 9
    s is 1
    ... and so on till z which is 8.

    How should I do this?

    Thanks

    Eli

  4. #4
    Join Date
    Aug 2004
    Posts
    43,023

    Re:Re:Re:Need help about text box

    [Originally posted by Jim]

    use mod

    eg.
    (asc(ucase("A"))-64) mod 9 = 1
    (asc(ucase("J"))-64) mod 9 = 1

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center