Results 1 to 7 of 7

Thread: psoitioning text in textbox

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Aug 1999
    Location
    Glasgow,Scotland
    Posts
    281

    Angry


    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."


  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    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






    Mark
    -------------------

  3. #3
    Lively Member
    Join Date
    Mar 2000
    Location
    Lowestoft
    Posts
    91
    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
    Mag-Net's Home
    Visual Studio 6-Enterprise - SP4
    ICQ: 35519773
    Have Fun

  4. #4
    Addicted Member
    Join Date
    Apr 2000
    Location
    Sheffield, England.
    Posts
    136
    ...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??!

  5. #5
    Addicted Member
    Join Date
    Apr 2000
    Location
    Sheffield, England.
    Posts
    136
    Er... one more thing! Don't forget to set Text1's MultiLine property to TRUE, otherwise Mark Sreeves' code will make little difference.

  6. #6
    Lively Member
    Join Date
    Feb 1999
    Location
    France
    Posts
    90

    Thumbs up


    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 & "".


  7. #7
    Guest
    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!"

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