• Status: Solved
  • Priority: Low
  • Security: Public
  • Views: 37
  • Last Modified:

Drawing Boxes in Visual Basic 6

Hi Experts!

I've written dozens of Visual Basic programs in my life but never touched graphics programming and I want to be able to draw on a form just boxes, rows and columns of boxes depending on the parameters I set. It could be a 10 x 10 set of boxes, a 50 x 100 set of boxes, etc. I have no idea how to do this. Can you help?

Have a great day :)
0
Ed Matsuoka
Asked:
Ed Matsuoka
  • 5
  • 5
2 Solutions
 
Martin LissOlder than dirtCommented:
Here Picture1 is a PictureBox.
Option Explicit
Private Declare Function TextOutW Lib "gdi32.dll" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal lpString As String, ByVal nCount As Long) As Long

Private Sub Command1_Click()
Picture1.Line (500, 500)-(4000, 500), vbRed
Picture1.Line (4000, 3000)-(4000, 500), vbGreen
Picture1.Line (500, 3000)-(4000, 3000), vbBlue
Picture1.Line (500, 3000)-(500, 500)

Picture1.CurrentX = 750
Picture1.CurrentY = 750
Picture1.FontSize = 16
Picture1.Print "Some text inside a box"

End Sub

Open in new window

0
 
Martin LissOlder than dirtCommented:
Here's a project.
29084837.zip
0
 
Ed MatsuokaPartner/Senior IT SpecialistAuthor Commented:
Hi Martin!

Here is what I want to do. I have data, anywhere from 50 by 50 to 500 by 5000 that I want to be able to display graphically as either a GREEN box (GOOD) , a YELLOW box (NEUTRAL) or a RED box (BAD). I wrote one in Excel using cells and it was ridiculously slow so I think VB6 should be much faster.

Any ideas!
PictureBoxExample1.png
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

 
NorieVBA ExpertCommented:
Ed

How did you do it in Excel?
0
 
Martin LissOlder than dirtCommented:
Try this workbook which colors cells in A1:F13 if the value is 1, 2 or 3. It uses Conditional Formatting.
29084837.xlsx
0
 
Ed MatsuokaPartner/Senior IT SpecialistAuthor Commented:
Thanks, I will! Here is my solution in Excel. It works well but when I get to 10,000 it gets slow. If I use it I will zoom the view depending on
how many rows/columns I am showing but I still suspect a graphic plot would be faster. What do you think?
ShowDATdata.xlsm
DummyData_352_Rows.txt
0
 
Martin LissOlder than dirtCommented:
Did you see my workbook?
1
 
Ed MatsuokaPartner/Senior IT SpecialistAuthor Commented:
Yes, just getting ready to go home but I will check it out in the next couple of days.
0
 
Ed MatsuokaPartner/Senior IT SpecialistAuthor Commented:
I was looking for a "Visual Basic" graphics solution. Martin's solution works great but wasn't the ideal I'd hoped for since (and I certainly could be wrong about this) I think a graphics solution would be faster and more easier scalable.
0
 
Martin LissOlder than dirtCommented:
I’m glad I was able to help.

If you expand the “Full Biography” section of my profile you’ll find links to some articles I’ve written that may interest you.

Marty - Microsoft MVP 2009 to 2017
              Experts Exchange Most Valuable Expert (MVE) 2015, 2017
              Experts Exchange Top Expert Visual Basic Classic 2012 to 2017
0
 
Ed MatsuokaPartner/Senior IT SpecialistAuthor Commented:
Great, I'll check them out.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

  • 5
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now