|
-
Sep 26th, 2000, 06:39 AM
#1
Thread Starter
Lively Member
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!
-
Sep 26th, 2000, 06:45 AM
#2
transcendental analytic
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.
-
Sep 26th, 2000, 06:48 AM
#3
Next to the .FontSize = 14 line, put this line:
Code:
Picture1.FontUnderline = True
-
Sep 26th, 2000, 06:49 AM
#4
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]
-
Sep 26th, 2000, 06:52 AM
#5
transcendental analytic
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.
-
Sep 26th, 2000, 07:11 AM
#6
Thread Starter
Lively Member
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.
-
Sep 26th, 2000, 07:17 AM
#7
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.
-
Sep 26th, 2000, 07:50 AM
#8
transcendental analytic
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.
-
Sep 26th, 2000, 08:08 AM
#9
-
Sep 26th, 2000, 10:38 AM
#10
Thread Starter
Lively Member
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.
-
Sep 26th, 2000, 10:46 AM
#11
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
-
Sep 26th, 2000, 12:37 PM
#12
Thread Starter
Lively Member
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!
-
Sep 26th, 2000, 02:32 PM
#13
It should look like this:
Code:
Public Sub WriteUnderline(x As String)
Now it also works for strings.
-
Sep 26th, 2000, 02:36 PM
#14
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]
-
Sep 27th, 2000, 04:59 AM
#15
transcendental analytic
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|