-
Hi there,
I put a grumpy face as my icon because I've been at this for 3 hours.
I've got some code that was written for a picturebox, but I need to change it to a textbox. Mostly this involves changing Picturebox1.Print to Text1.Tex, but I'm having difficulty with the positioning. For example, with Picturebox1.Print in the place of Text1.Text below, the code works as it should, but with Text1.Text only the last line, 'Work out the answer on your notepad' is displayed.
It should read like:
---------
Upper Expression: (1)(6x-4=20)
Lower Expression: (2)(3x+5=17)
Work out the answer on your notepad.
----------
What must I do with my code to display all this in textbox?
Thanks for any help!
With Text1 'positioning
.FontSize = 22
End With
Text1.Text = "Upper expression:"
Text1.FontSize = 22
If mul Then
If tmp1 Then
Text1.Text = "(" & Trim$(mul) & ")"
Else
Text1.Text = "(1)"
End If
Else
If xory = "x" Then
Text1.Text = "(" & Trim$(c) & ")"
Else
Text1.Text = "(" & Trim$(d) & ")"
End If
End If
Text1.Text = "(" & Trim$(a) & "x"
If b > -1 Then Text1.Text = "+"
Text1.Text = Trim$(b) & "=" & Trim$(a * x + b * y) & ")"
Text1.Text = "Lower expression:"
If mul Then
If tmp1 Then
Text1.Text = "(1)"
Else
Text1.Text = "(" & Trim$(mul) & ")"
End If
Else
If xory = "x" Then
Text1.Text = "(" & Trim$(a) & ")"
Else
Text1.Text = "(" & Trim$(b) & ")"
End If
End If
Text1.Text = "(" & Trim$(c) & "x"
If d > -1 Then Text1.Text = "+"
Text1.Text = Trim$(d) & "=" & Trim$(c * x + d * y) & ")"
Text1 = "Work out the answer on your notepad."
-
Your code is near incomprehensible :)
But I can see straight away that
Text1 = "Work out the answer on your notepad."
Ought to be
Text1 = Text1 & "Work out the answer on your notepad."
otherwise you are just overwriting whatever is already in text1.text
-
The TAB key makes a world of difference you know! If I were you, i would indent a lot of that to make it read easier, and also use variable names that mean something :)
-
...and since all your code is relating to 'Text1', why didn't you put your 'End With' at the end of this code?
Yeah the code might be untidy, but if it works and the programmer understands it, who cares??!
-
Er... one more thing! Don't forget to set Text1's MultiLine property to TRUE, otherwise Mark Sreeves' code will make little difference.
-
Thanks for the help. Actually the code makes perfect sense in the context of all the other code. I'll have a go at the Text1=Text1 & "".
-
Or you can use the Chr$(9) function which is like pressing the tab key :).
Code:
Text1.text = "Hello." & Chr$(9) & "Welcome to Vb-world.net!"