Results 1 to 15 of 15

Thread: drawing a line under a string or integer?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 1999
    Location
    France
    Posts
    90

    Hi,

    Does anybody know how I can draw a horizontal line under a string or integer?

    The problem is that I don't want to hardcode the line because the position of the integer will change.

    'command button and picturebox
    Private Sub Command1_Click()
    Dim number As Integer
    Randomize
    number = Int(Rnd * 200)
    Picture1.Cls
    Picture1.FontSize = 14
    picture1.print number
    end sub

    How could I have it so that, regardless of whether I have:

    picture1.print number
    or
    picture1.print " " & number
    or
    picture1.print "You will see that the answer is " & _
    number & ", so you have failed the test."

    the line will always appear under the integer, number?

    Thanks for any help!

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Code:
    Picture1.Font.Underline = True
    Picture1.Print "Whatever"
    Picture1.Font.Underline = false
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  3. #3
    Guest
    Next to the .FontSize = 14 line, put this line:
    Code:
    Picture1.FontUnderline = True

  4. #4
    Guest
    Oooooohh... You got me kedaman....
    BTW, there shouldn't be a period between Font and Underline.

    [Edited by Sc0rp on 09-26-2000 at 07:53 AM]

  5. #5
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Hehe, 1 minute
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Feb 1999
    Location
    France
    Posts
    90

    Hi,

    Either what you gave me doesn't work or I picked you up wrong.

    I put what you gave me as a Function so I could call it when I wanted:


    Private Sub Command1_Click()
    Dim number As Integer
    Randomize
    number = Int(Rnd * 200)
    Picture1.Cls
    Picture1.FontSize = 14
    Picture1.Print "The number is " & lineunder(number)
    End Sub

    Public Function lineunder(x As Integer)
    Picture1.Font.Underline = True
    Picture1.Print x
    Picture1.Font.Underline = False
    End Function

    --------

    number is printed at the top of my picturebox, whereas it should be printed next to, "The number is "

    Do you know why this is happening and how it can be solved?

    Thanks.

  7. #7
    Guest
    You might wanna try this:
    Code:
    Private Sub Command1_Click() 
    
        Dim number As Integer 
        Randomize 
        number = Int(Rnd * 200) 
    
        Picture1.Cls 
        Picture1.FontSize = 14 
        Picture1.Print "The number is "
        WriteUnderline number
    
    End Sub 
    
    Public Sub WriteUnderline(x As String) 
    
        Picture1.Font.Underline = True 
        Picture1.Print x
        Picture1.Font.Underline = False
    
    End Function
    I think that this will work.

  8. #8
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Almost Sc0rp, almost
    Code:
    Picture1.Print "The number is ";
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

  9. #9
    Guest

    Thumbs up


  10. #10

    Thread Starter
    Lively Member
    Join Date
    Feb 1999
    Location
    France
    Posts
    90

    I got an error with WriteUnderline number but I changed it to WriteUnderLine(number) and it worked better.

    But it's not as effective as I want it to be. I want a function that can be called throughout my project for different integers.

    E.g:

    Picture1.print "If the first number is " & WriteUnderLine(primenumber) & " what is the second one?"
    'underline WriteUnderLine(primenumber) only

    And somewhere else in my project:

    Picture1.print "What is " & WriteUnderLine(evennumber) &
    " squared?"
    'underline WriteUnderLine(evennumber) only

    And my function is:

    Public Sub WriteUnderline(x As String)

    Picture1.Font.Underline = True
    Picture1.Print x
    Picture1.Font.Underline = False

    End Sub

    -----

    Well at present, everything is underlined after WriteUnderLine. In my first example, WriteUnderLine(primenumber) & " what is the second one?", is underlined, whereas all I want is WriteUnderLine(primenumber).

    How can I have it so that only the part in brackets is underlined?

    Any ideas?

    Thanks.

  11. #11
    Guest
    You could try sending 3 strings: B4Underling, underline, AFTRUnderine.

    and constitue the text in the control from the strings. Note that if you sent "",5,"" you would get only the underlined string.

    This would also allow this to be used in other situations where the arguments are not necessarily integers, reals, or whatever.



    Good Luck
    DerFarm

  12. #12

    Thread Starter
    Lively Member
    Join Date
    Feb 1999
    Location
    France
    Posts
    90

    Cool

    Ah hah!

    I got it.

    I was leaving out the ; in the function:

    Public Function WriteUnderline(x As Integer) As String
    Picture1.Font.Underline = True
    Picture1.Print x; 'forgot the ;
    Picture1.Font.Underline = False
    End Function

    Now it works - with integers only. How can I have it so that it also works with strings. What do I have to change here:

    Public Function WriteUnderline(x As Integer) As String

    Thanks!

  13. #13
    Guest
    It should look like this:
    Code:
    Public Sub WriteUnderline(x As String)
    Now it also works for strings.

  14. #14
    Guest
    Example:
    Code:
    Print "Hello, welcome to ";
    WriteUnderline "my"
    Print " world."
    will return:
    Hello, welcome to my world.

    [Edited by Sc0rp on 09-26-2000 at 03:43 PM]

  15. #15
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    Change it to variant and it'll work for both strings and integer. In fact you can print datatypes except arrays, UDT's and objects.
    Use
    writing software in C++ is like driving rivets into steel beam with a toothpick.
    writing haskell makes your life easier:
    reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
    To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.

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