Results 1 to 7 of 7

Thread: drawing the function graphic

  1. #1

    Thread Starter
    Member
    Join Date
    Oct 2011
    Posts
    53

    drawing the function graphic

    Hi friends,

    I want to ask a question about drawing a graphic

    these are my code

    vb Code:
    1. Option Explicit
    2.  
    3. Const i3 As Integer = 1
    4. Const i2 As Integer = 2
    5. Const i1 As Integer = 1
    6. Const xmin As Integer = -10
    7. Const xmax As Integer = 10
    8. Const ymin As Integer = 0
    9. Const ymax As Integer = 121
    10. Const N As Integer = 20
    11.  
    12.  
    13.  
    14.  
    15. Private Sub Form_Load()
    16. Dim i As Integer
    17. Dim A As Double
    18.  
    19.  
    20.     Scale (xmin, ymax)-(xmax, ymin)
    21.     Line (xmin, 0)-(xmax, 0)
    22.     Line (0, ymin)-(0, ymax)
    23.     PSet (xmin, Pol(xmin))
    24.    
    25.         For i = xmin To xmax Step (xmax - xmin) / N
    26.             A = Pol(i)
    27.             Line -(i, A)
    28.             Circle (i, A), 0.005
    29.         Next
    30.        
    31.            
    32. End Sub
    33.  
    34. Function Pol(x As Integer) As Double
    35.  Dim y As Double
    36.     y = i3 * x * x + i2 * x + i1
    37.     Pol = y
    38.    
    39. End Function


    This is the graphic which the programme drew




    This is what I want





    What should I do?


    Edit: If you also say how I can make the program draw the graphic below, it will be awesome






    I chose x1,y1 randomly to tell what I want to make

    Thanks
    Last edited by _MeRKeZ_; Jan 7th, 2012 at 06:21 AM.

  2. #2
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,580

    Re: drawing the function graphic

    @_MeRKeZ_
    Try to change ymin and ymax to
    vb Code:
    1. Const ymin As Integer = -60
    2. Const ymax As Integer = 60

    @Nightwalker83
    Because the drawing is in Form_Load event, the draw is disappear when showing the form, add Me.AutoRedraw = True at the beginning of the Form_Load code.



  3. #3
    PowerPoster Nightwalker83's Avatar
    Join Date
    Dec 2001
    Location
    Adelaide, Australia
    Posts
    13,346

    Re: drawing the function graphic

    Quote Originally Posted by 4x2y View Post
    @Nightwalker83
    Because the drawing is in Form_Load event, the draw is disappear when showing the form, add Me.AutoRedraw = True at the beginning of the Form_Load code.
    Yeah, I noticed that after I posted.
    when you quote a post could you please do it via the "Reply With Quote" button or if it multiple post click the "''+" button then "Reply With Quote" button.
    If this thread is finished with please mark it "Resolved" by selecting "Mark thread resolved" from the "Thread tools" drop-down menu.
    https://get.cryptobrowser.site/30/4111672

  4. #4

    Thread Starter
    Member
    Join Date
    Oct 2011
    Posts
    53

    Re: drawing the function graphic

    Thanks for helping me

    Why 0 and 121 cause that problem? Could you explain it?

    Can I make the programme draw last graphic?

  5. #5
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,580

    Re: drawing the function graphic

    Quote Originally Posted by _MeRKeZ_ View Post
    Thanks for helping me

    Why 0 and 121 cause that problem? Could you explain it?
    Because you are divide the plan to four quarters and at the same time you set xmin, xmax to -10, 10 so y should be the same.



  6. #6
    PowerPoster
    Join Date
    Sep 2006
    Location
    Egypt
    Posts
    2,580

    Re: drawing the function graphic

    Quote Originally Posted by _MeRKeZ_ View Post
    Can I make the programme draw last graphic?
    Are you want to draw lines according to x1 and y1? if so, try this
    vb Code:
    1. Private Sub Command1_Click()
    2.     Dim x1 As Double
    3.     Dim y1 As Double
    4.    
    5.     x1 = -5.6
    6.     y1 = 21
    7.    
    8.     Line (x1, 0)-(x1, y1)
    9.     Line (0, y1)-(x1, y1)
    10. End Sub



  7. #7

    Thread Starter
    Member
    Join Date
    Oct 2011
    Posts
    53

    Re: drawing the function graphic

    I want those values to seem on the graphic as I gave the example above

Tags for this Thread

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