-
Thanks for the code, thats exactly what I was looking for, but I need something also. Heres my problem.
I wanna make a visual keyboard program. and im gonna make little buttons and basicaly do the code you gave me. But I can make it sorta like if I press a button (EXAMPLE)
called A and i made it out put A and then I had a Button B (same thing). How do you make it so that it adds it to what i already have. So its not A then B, but AB?
Hope I didn't confuse u, and any other cool helpin' nerds are welcome to help me!
-
I'm not sure I exactly understand.
You want to line them like:
ABCDEFGHIJKLMNOPQRSTUVWXYZ
And the code used for it would be:
Code:
Combo1.text = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
or like this:
A
B
C
D
E
F
G
H
I
J
K
L
M
N
O
P
Q
R
S
T
U
V
W
X
Y
Z
And the code would be something like:
Code:
combo1.additem "A"
combo1.additem "B"
combo1.additem "C"
combo1.additem "D"
combo1.additem "E"
combo1.additem "F"
combo1.additem "G"
combo1.additem "H"
combo1.additem "I"
combo1.additem "J"
combo1.additem "K"
combo1.additem "L"
combo1.additem "M"
combo1.additem "N"
combo1.additem "O"
combo1.additem "P"
combo1.additem "Q"
combo1.additem "R"
combo1.additem "S"
combo1.additem "T"
combo1.additem "U"
combo1.additem "V"
combo1.additem "W"
combo1.additem "X"
combo1.additem "Y"
combo1.additem "Z"
That what your trying to do?
-
Example
Ok Im making a program that is just a picture of a keyboard with all the little ABCD keys. And Im going to make Command Buttons with captions A, B, ect... And The Im Going to have a Test Area. And with your code If I were to press the A button I am going to program is to make A (like a working keyboard). But heres my problem, when I go to press B the text box erases the A and puts in the B, now I wan't it so instead of erasing the A is keeps it there so the end product would be: AB.
I hope you understand now! Thanks 4 ur help
-
Try:
Code:
'Text1.text = "A"
Text1.text = Text1.text + "B"
'Results: Text1.text = "AB"
-
Matthew:
Its always better to use the & Operator.
Code:
Text1.Text = Text1.Text & "B"
if you want the return value to be a Concatenated string Always use &.
Code:
MsgBox 1 + 2 ' returns 3 as an integer
MsgBox 1 & 2 ' returns 12 as a string
-
I would suggest the following: Have a control array of 26 command buttons, each representing a letter. Call them cmdLetter, with their Index properties set from 0 to 25 (so cmdLetter(0) is "A", cmdLetter(2) is "B", ... cmdLetter(25) is "Z"). Assume the Caption properties for each of these is set to that letter ("A", "B", "C", etc.)
Your code for the cmdLetter_Click event would look like this (using concatenation as Matthew and Dennis suggest, with the & operator preferred as Dennis mentioned):
Code:
Private Sub cmdLetter_Click(Index As Integer)
Text1.Text = Text1.Text & cmdLetter(Index).Caption
End Sub
You may also want to have a clear button (say "cmdClear") and a Backspace button so you can simulate deleting text ("cmdBackspace").
Code:
Private Sub cmdClear_Click()
Text1.Text = ""
End Sub
Private Sub cmdBackspace_Click()
Dim intLength As Integer
intLength = Len(Text1.Text)
If intLength > 0 Then
Text1.Text = Left$(Text1.Text, intLength - 1)
End If
End Sub