phantom coder Level: Trainee
 Registered: 28-10-2009 Posts: 1
|
Dynamic Changing Text... Please Help me.
I have 3 textboxes and 3 labels and using the keypress event i can get it to dynamically change the text in the labels correct except the first letter does not show up until i press the second letter and the last letter does not show up until i press another key.
Also on the formatting issues the third format where I use a , in the formatting it shows up like this in the label.text as ,Phanto until i switch to another textbox and press a key then it will show up as Pantom, the m shows up and the comma goes tot he correct place and if i press another key then the C in coder shows up but the o in coder is still not there until i press another key.
the follow is the code im using.
Public Class Form1
'Declare the varibles
Dim FirstText As String
Dim MiddleText As String
Dim LastText As String
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'Initializes the varibles
FirstText = ""
MiddleText = ""
LastText = ""
Label5.Text = FirstText
Label6.Text = MiddleText
Label7.Text = LastText
End Sub
Private Sub TextBox1_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox1.KeyPress
'Combines all the data into a string
FirstText = TextBox1.Text + " " + TextBox2.Text + " " + TextBox3.Text
MiddleText = TextBox3.Text + " " + TextBox1.Text + " " + TextBox2.Text
LastText = TextBox3.Text + ", " + TextBox1.Text + " " + TextBox2.Text
'Fills the label.text fields
Label5.Text = FirstText
Label6.Text = MiddleText
Label7.Text = LastText
End Sub
Private Sub TextBox2_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox2.KeyPress
FirstText = TextBox1.Text + " " + TextBox2.Text + " " + TextBox3.Text
MiddleText = TextBox3.Text + " " + TextBox1.Text + " " + TextBox2.Text
LastText = TextBox3.Text + ", " + TextBox1.Text + " " + TextBox2.Text
Label5.Text = FirstText
Label6.Text = MiddleText
Label7.Text = LastText
End Sub
Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress
FirstText = TextBox1.Text + " " + TextBox2.Text + " " + TextBox3.Text
MiddleText = TextBox3.Text + " " + TextBox1.Text + " " + TextBox2.Text
LastText = TextBox3.Text + ", " + TextBox1.Text + " " + TextBox2.Text
Label5.Text = FirstText
Label6.Text = MiddleText
Label7.Text = LastText
End Sub
End Class
|
With the combobox i really have a problem but that can be sorted out after i get the dynamic text updating to work properly.
anyhelp will be greatfull I looked for a change or onchange event within the textbox but found none, i also tryied textchanged event and it did not work at all.
BTW i use vb.net 2k3,2k5,2k8 and 2k10
____________________________
All Things Possible Thru Code!
The Phantom
|