|
-
May 18th, 2010, 09:22 PM
#1
Thread Starter
Fanatic Member
[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?
-
May 18th, 2010, 10:15 PM
#2
Re: What is wrong with my code? Print the text onto the form? Help plz!
try
me.autoredraw = true
before printing to the form
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
May 18th, 2010, 10:52 PM
#3
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.
-
May 19th, 2010, 02:39 AM
#4
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"
.....
If my post was helpful to you, then express your gratitude using Rate this Post. 
And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet
Social Group: VBForums - Developers from India
Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...
-
May 19th, 2010, 02:47 AM
#5
Junior Member
Re: What is wrong with my code? Print the text onto the form? Help plz!
-
May 19th, 2010, 02:52 AM
#6
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.
-
May 19th, 2010, 08:11 AM
#7
Hyperactive Member
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.
If your problem is solved, then drag down the Thread Tools and mark your thread as Resolved.
If I helped you solve your problem, inflate some air into my ego by rating my post and adding a comment too.
For notorious issues (elaborate yourself) contact me via PM. I don't answer them in the forums EVER.
-
May 19th, 2010, 01:25 PM
#8
Thread Starter
Fanatic Member
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.
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
|