Important alert: (current site time 7/16/2013 12:35:12 AM EDT)
 

article

Using the Line control to achieve nice looking graphics

Email
Submitted on: 4/1/2013 12:24:27 PM
By: A_X_O 
Level: Beginner
User Rating: By 6 Users
Compatibility: VB 3.0, VB 4.0 (16-bit), VB 5.0, VB 6.0
Views: 2379
(About the author)
 
     Using the Line Control to create a colored bar chart.


 
 
Terms of Agreement:   
By using this article, you agree to the following terms...   
  1. You may use this article in your own programs (and may compile it into a program and distribute it in compiled format for languages that allow it) freely and with no charge.
  2. You MAY NOT redistribute this article (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
  3. You may link to this article from another website, but ONLY if it is not wrapped in a frame. 
  4. You will abide by any additional copyright restrictions which the author may have placed in the article or article's description.
				Private Sub Form_Click()
On Error Resume Next
'Modified msdn sample
Dim I, OldFontSize ' Declare variables.
Width = 8640: Height = 5760 ' Set form size in twips.
Move 100, 100' Move form origin.
AutoRedraw = -1 ' Turn on AutoRedraw.
OldFontSize = FontSize ' Save old font size.
BackColor = QBColor(7)' Set background to gray.
Scale (0, 110)-(130, 0)' Set custom coordinate system.
For I = 100 To 10 Step -10
Line (0, I)-(2, I) ' Draw scale marks every 10 units.
CurrentY = CurrentY + 1.5' Move cursor position.
Print I ' Print scale mark value on left.
Line (ScaleWidth - 2, I)-(ScaleWidth, I)
CurrentY = CurrentY + 1.5' Move cursor position.
CurrentX = ScaleWidth - 9
Print I ' Print scale mark value on right.
Next I
' Draw bar chart.
Line (10, 0)-(20, 45), RGB(0, 0, 255), BF' First blue bar.
Line (20, 0)-(30, 55), RGB(255, 0, 0), BF' First red bar.
Line (40, 0)-(50, 40), RGB(0, 0, 255), BF
Line (50, 0)-(60, 25), RGB(255, 0, 0), BF
Line (70, 0)-(80, 35), RGB(0, 0, 255), BF
Line (80, 0)-(90, 60), RGB(255, 0, 0), BF
Line (100, 0)-(110, 75), RGB(0, 0, 255), BF
Line (110, 0)-(120, 90), RGB(255, 0, 0), BF
CurrentX = 18: CurrentY = 100' Move cursor position.
FontSize = 14' Enlarge font for title.
Print "Hat Quarterly Sales" ' Print title.
FontSize = OldFontSize ' Restore font size.
CurrentX = 27: CurrentY = 93' Move cursor position.
Print "Planned And Actual Sales"' Print subtitle.
Line (29, 86)-(34, 88), RGB(0, 0, 255), BF ' Print legend.
Line (43, 86)-(49, 88), RGB(255, 0, 0), BF
End Sub


Other 8 submission(s) by this author

 


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this article (in the Beginner category)?
(The article with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)
 

Other User Comments
4/2/2013 3:03:54 PMBill K of Boston

short, sweet, deadly effective !
5 stars here
(If this comment was disrespectful, please report it.)

 
4/22/2013 1:52:14 AMThePiper

That's typically VB6: A easy to use, highly effective, Fast Prototyping Tool.
Always good for surprising solutions when a genius like A_X_O is working with... :-)
Thanks A_X_O, well done!

(If this comment was disrespectful, please report it.)

 
4/24/2013 1:05:27 PMSimo Simo

yep, it's simple and extremely powerful

5 Stars
(If this comment was disrespectful, please report it.)

 

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)
 

To post feedback, first please login.