Advertisement
Guest User

Untitled

a guest
Dec 15th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. Dim k As Integer
  2. Dim t, R1, R2, f1, f2 As Double
  3. Function fS(Radius, w, t As Double) As Double
  4. fS = Radius * Sin(w * t)
  5. End Function
  6. Function fC(Radius, w, t As Double) As Double
  7. fC = Radius * Cos(w * t)
  8. End Function
  9. Sub mForm1()
  10. f1 = 1: f2 = 1
  11. R1 = 5: R2 = 1
  12. With UserForm1
  13. .TextBox1.Text = f1
  14. .TextBox2.Text = f2
  15. .TextBox3.Text = R1
  16. .TextBox4.Text = R2
  17. .Show
  18. End With
  19. End Sub
  20. Sub mGraph()
  21. k = 0
  22. Pi = Application.Pi
  23. f1 = Val(UserForm1.TextBox1.Text)
  24. f2 = Val(UserForm2.TextBox2.Text)
  25. R1 = Val(UserForm3.TextBox3.Text)
  26. R2 = Val(UserForm4.TextBox4.Text)
  27. For t = 0 To 2 * Pi Step Pi / 100
  28. k = k + 1
  29. Cells(k, 1) = fC(R1, f1, t)
  30. Cells(k, 2) = fS(R2, f2, t)
  31. Next t
  32. ActiveSheet.Shapes.AddChart.Select
  33. With ActiveChart
  34. .ChartType = xlXYScatterLinesNoMarkers
  35. .SetSourceData Source:=Range(Cells(1, 1), Cells(k, 2))
  36. End With
  37. End Sub
  38.  
  39.  
  40. End Sub
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50. Private Sub CommandButton1_Click()
  51. Call mGraph
  52. End Sub
  53.  
  54. Private Sub CommandButton2_Click()
  55. Cells.Clear
  56. For Each i In ActiveSheet.Shapes
  57. i.Delete
  58. Next i
  59. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement