[RESOLVED] What is wrong with my code? Print the text onto the form? Help plz!
here is my code:
Code:
Private Sub tmrHighScore_Timer()
Dim quads
For quads = 1 To i
If playerscore < scorenum(quads) Then
FontSize = 10
Print scorenum(quads) & ""
ElseIf playerscore > scorenum(quads) And overdo = True Then
scorenum(quads) = playerscore
FontSize = 20
Print scorenum(quads) & ""
overdo = False
ElseIf overdo = False Then
FontSize = 10
Print scorenum(quads) & ""
End If
Next quads
End Sub
I get no errors or anything.... What is the problem?
Re: What is wrong with my code? Print the text onto the form? Help plz!
try
me.autoredraw = true
before printing to the form
Re: What is wrong with my code? Print the text onto the form? Help plz!
What's i? If it's zero(or uninitialized), the loop will not be entered.
What's quads, why is it a variant when it's used as an explicit number? Should probably be a long.
OverDo should be a boolean.
I'm guessing you don't use Option Explicit? Please consider it.
Re: What is wrong with my code? Print the text onto the form? Help plz!
Also, why are you using a Timer for printing the highscores (I believe it is ;))
If you use a PictureBox, then you will get more control over the printing and other things...
Eg:
Code:
Picture1.Print "Hi"
.....:wave:
Re: What is wrong with my code? Print the text onto the form? Help plz!
Re: What is wrong with my code? Print the text onto the form? Help plz!
You'll probably want to set the form's CurrentX and CurrentY before calling print statements.
As your code would eventually end up printing the text outside the viewable area.
Re: What is wrong with my code? Print the text onto the form? Help plz!
I believe the error is in your if-else structure:
Code:
For quads = 1 To i
If playerscore < scorenum(quads) Then
'do something
ElseIf playerscore > scorenum(quads) And overdo = True Then
'do something
ElseIf overdo = False Then
'do something
End If
Next quads
There could be 2 explanations of why nothing happens:
1- For quads=1 To i
Here if i is less than 1 then the loop will not start at all and nothing will happen.
2- If playerscore is EQUAL to scorenum(quads) and overdo=True then again no If condition will be satisfied and nothing will happen.
You should look upon these two possible logical weaknesses of your code and then see if something happens or not.
Re: What is wrong with my code? Print the text onto the form? Help plz!
Oh my gosh!!!!! XD I FEEL SO STUPID! I was reading from a .txt file, and i was printing that on the form.... Turns out, didnt have any text in the .txt file. XD Thanks anyways guys.