Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim k As Integer
- Dim t, R1, R2, f1, f2 As Double
- Function fS(Radius, w, t As Double) As Double
- fS = Radius * Sin(w * t)
- End Function
- Function fC(Radius, w, t As Double) As Double
- fC = Radius * Cos(w * t)
- End Function
- Sub mForm1()
- f1 = 1: f2 = 1
- R1 = 5: R2 = 1
- With UserForm1
- .TextBox1.Text = f1
- .TextBox2.Text = f2
- .TextBox3.Text = R1
- .TextBox4.Text = R2
- .Show
- End With
- End Sub
- Sub mGraph()
- k = 0
- Pi = Application.Pi
- f1 = Val(UserForm1.TextBox1.Text)
- f2 = Val(UserForm2.TextBox2.Text)
- R1 = Val(UserForm3.TextBox3.Text)
- R2 = Val(UserForm4.TextBox4.Text)
- For t = 0 To 2 * Pi Step Pi / 100
- k = k + 1
- Cells(k, 1) = fC(R1, f1, t)
- Cells(k, 2) = fS(R2, f2, t)
- Next t
- ActiveSheet.Shapes.AddChart.Select
- With ActiveChart
- .ChartType = xlXYScatterLinesNoMarkers
- .SetSourceData Source:=Range(Cells(1, 1), Cells(k, 2))
- End With
- End Sub
- End Sub
- Private Sub CommandButton1_Click()
- Call mGraph
- End Sub
- Private Sub CommandButton2_Click()
- Cells.Clear
- For Each i In ActiveSheet.Shapes
- i.Delete
- Next i
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement