Menu

Print numbers to LCD from right side

Help
Vaclav
2011-11-07
2013-05-30
  • Vaclav

    Vaclav - 2011-11-07

    Hi.
    Can you give me a help with aligment numbers from right side? I always use code like this:

    Sub LCDprodleva
    odpocet = prodleva - kontakt
    Locate 2,16
    If odpocet < 1000 then
    Print "0"
    End If
    If odpocet < 100 then
    Print "0"
    End If
    If odpocet < 10 then
    Print "0"
    End If
    Print odpocet
    If odpocet = 0 Then
    Locate 2,16
    Print "    "
    End If
    End Sub
    

    But I thing there must be a better way to do this.
    Thanks

     
  • Bert

    Bert - 2011-11-08

    I would eliminate one locate and any chance of a flicker this way:

    Sub LCDprodleva 
    odpocet = prodleva - kontakt 
    Locate 2,16 
    If odpocet = 0 Then 
      Print " " 
    Else
      Select Case odpocet 
      Case < 1000
        Print "0" 
      Case < 100
        Print "0" 
      Case < 10 
        Print "0" 
      End Select 
      Print odpocet 
    End If 
    End Sub
    

    -Bert

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.