Results 1 to 5 of 5

Thread: Draw graph on picture box

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2005
    Posts
    12

    Draw graph on picture box

    Hi
    I need to plot a series graph ( x-axis is 'time in minute',y-axis is data) on a picture box uisng VB6.0 ( no dotNET). The data are from a data file named mydata.txt.
    But I have not figure out how to do it . could somebody pls show me how?

    Thanks

  2. #2
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Draw graph on picture box


  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2005
    Posts
    12

    Re: Draw graph on picture box

    Hi Lintz
    I tried , but I need to read data from the datafile, how?
    I also need a scaled x,y axis.
    Thanks

  4. #4
    PowerPoster lintz's Avatar
    Join Date
    Mar 2003
    Location
    The 19th Hole
    Posts
    2,697

    Re: Draw graph on picture box

    I'm not sure about the scales (but I wouldn't mind knowing myself ) but this will open a file and plot the data.

    VB Code:
    1. Private Sub Form_Load()
    2. Dim xPoint  As Single
    3. Dim yPoint As Single
    4. Dim s As String
    5. Dim PlotData() As String
    6.  
    7. Picture1.ScaleHeight = 100
    8. Picture1.ScaleWidth = 100
    9.  
    10. FirstValue = True
    11.  
    12. Open "C:\MyData.txt" For Input As #1
    13.  
    14. Do Until EOF(1) = True
    15.  
    16. Line Input #1, s
    17. PlotData = Split(s, ",")
    18.  
    19. Picture1.Line (xPoint, yPoint)-(PlotData(0), PlotData(1))
    20.  
    21. xPoint = PlotData(0)
    22. yPoint = PlotData(1)
    23.  
    24. Loop
    25.  
    26. Close #1
    27. End Sub
    Last edited by lintz; Oct 12th, 2005 at 01:08 AM.

  5. #5

    Thread Starter
    New Member
    Join Date
    Sep 2005
    Posts
    12

    Re: Draw graph on picture box

    Hi Lintz

    Thank you very much

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