Results 1 to 6 of 6

Thread: Connecting 2 Text Boxes So That 1=2, and 2=1

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Location
    Texas
    Posts
    26

    Cool

    Ok, heres the scoop:
    I have two text boxes, I want to set it up so that if someone entered:
    "blah"
    into the first text box, the second text box would display
    "boo!"
    etc...

    Anyone know?

    Thanks,
    System

  2. #2
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    Option Explicit

    Private Sub Text1_Change()
    If Text1 = "blah" Then Text2 = "boo"
    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Location
    Texas
    Posts
    26

    Exclamation Almost

    If in text1 someone enters "A",
    I want text2 to output "1".

    If in text1 someone enters "B",
    I want text2 to output "2".

    But if someone entered "AB",
    I want it to display "12". Not 1.

    That might be confusing, lt me know if you need any further explaning.

    Thanks,
    System

  4. #4
    _______ HeSaidJoe's Avatar
    Join Date
    Jun 1999
    Location
    Canada
    Posts
    3,946

    <?>

    same old just a little more work to do
    you need to look up the ascii character set
    for example a = 97

    'and on and on

    Private Sub Text1_KeyPress(KeyAscii As Integer)

    Dim strString
    strString = Text2.Text

    If KeyAscii = 97 Then Text2 = strString & 1
    If KeyAscii = 98 Then Text2 = strString & 2

    End Sub
    "A myth is not the succession of individual images,
    but an integerated meaningful entity,
    reflecting a distinct aspect of the real world."

    ___ Adolf Jensen

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Sep 2000
    Location
    Texas
    Posts
    26
    Sorry, I am confused.

    What I am trying to do, is make a program that when you enter letters and numbers into text1, text2 will output the binary form of those letters.

    EX:
    Someone enters:
    "ABC" into text1,
    text2 will output:
    "010000010100001001000011".

    But I can't enter all the binary for each word, so i need each letter or number to addon its code to the nubers the text2.

    -System

  6. #6
    Guest
    I take no credit for these functions(Base2Dec, and Dec2Base) Kedaman wrote them...

    Code:
    Function Base2Dec(val$, base%): Dim n%, a() As Byte
        a = StrConv(UCase(val), vbFromUnicode)
        For n = 1 To Len(val)
            Base2Dec = CDec(Base2Dec + (a(n - 1) - 48 + 7 * (a(n - 1) > 64)) * base ^ (Len(val) - n))
        Next n
    End Function
    
    Function Dec2Base$(val, base%): Dim n%, s
        For n = 0 To 100
            s = Int(val / base ^ n)
            If s = 0 Then Exit For
            s = s - Int(s / base) * base 's mod base
            Dec2Base = Chr(s + 48 - 7 * (s > 9)) & Dec2Base
        Next n
    End Function
    
    Private Sub Form_Load()
        Text1 = ""
        Text2 = ""
    End Sub
    
    Private Sub Text1_KeyPress(KeyAscii As Integer)
        Text2 = Text2 & " " & Dec2Base(KeyAscii, 2)
    End Sub

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width