Results 1 to 8 of 8

Thread: [RESOLVED] What is wrong with my code? Print the text onto the form? Help plz!

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2009
    Location
    Missouri
    Posts
    770

    Resolved [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?
    Rate my post if i helped you!


    Button Configuration Control For VB6 GetAsyncKeyState
    I'm the 7th best high school programmer in the nation!(according to SkillsUSA Nationals)(Used C#.Net)

  2. #2
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  3. #3
    Fanatic Member FireXtol's Avatar
    Join Date
    Apr 2010
    Posts
    874

    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.

  4. #4
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

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

  5. #5
    Junior Member
    Join Date
    May 2010
    Posts
    19

    Re: What is wrong with my code? Print the text onto the form? Help plz!

    Form1.AutoRedraw = True

  6. #6
    Fanatic Member FireXtol's Avatar
    Join Date
    Apr 2010
    Posts
    874

    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.

  7. #7
    Hyperactive Member
    Join Date
    Jan 2006
    Location
    Pakistan
    Posts
    388

    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.

  8. #8

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2009
    Location
    Missouri
    Posts
    770

    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.
    Rate my post if i helped you!


    Button Configuration Control For VB6 GetAsyncKeyState
    I'm the 7th best high school programmer in the nation!(according to SkillsUSA Nationals)(Used C#.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