Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Dim p As Integer '第四題用來記錄游標在text2中的位置
- Private Sub Command1_Click()
- '第一題,計算刺突個數
- a = Split(Text2, Text1)
- Label3 = UBound(a)
- End Sub
- Private Sub Command2_Click()
- Command1_Click
- '第二題,畫出刺突,簡化為2D
- Me.Cls '清除form上面的所有作畫
- Me.DrawWidth = 2
- X1 = (Image1.Left + Image1.Width / 2)
- Y1 = (Image1.Top + Image1.Height / 2)
- Me.Circle (X1, Y1), 2000, vbRed
- Me.DrawWidth = 6
- For i = 1 To Label3
- X1 = (Image1.Left + Image1.Width / 2) + 2000 * Cos(i / Label3 * 2 * 3.14)
- Y1 = (Image1.Top + Image1.Height / 2) + 2000 * Sin(i / Label3 * 2 * 3.14)
- X2 = (Image1.Left + Image1.Width / 2) + 2300 * Cos(i / Label3 * 2 * 3.14)
- Y2 = (Image1.Top + Image1.Height / 2) + 2300 * Sin(i / Label3 * 2 * 3.14)
- Line (X1, Y1)-(X2, Y2), vbRed
- Me.Circle (X2, Y2), 200, vbRed
- Me.FontSize = 16
- Print i
- Next
- End Sub
- Private Sub Command3_Click()
- Command1_Click
- '第三題,畫出刺突,簡化為2D,中間畫3個
- Me.Cls '清除form上面的所有作畫
- Me.DrawWidth = 2
- X1 = (Image1.Left + Image1.Width / 2)
- Y1 = (Image1.Top + Image1.Height / 2)
- Me.Circle (X1, Y1), 2000, vbRed
- Me.DrawWidth = 6
- For i = 1 To 3
- X2 = (Image1.Left + Image1.Width / 2) + 1000 * Cos(i / 3 * 2 * 3.14)
- Y2 = (Image1.Top + Image1.Height / 2) + 1000 * Sin(i / 3 * 2 * 3.14)
- Me.Circle (X2, Y2), 200, vbRed
- Me.FontSize = 16
- Print i
- Next
- For i = 1 To Label3 - 3
- X1 = (Image1.Left + Image1.Width / 2) + 2000 * Cos(i / (Label3 - 3) * 2 * 3.14)
- Y1 = (Image1.Top + Image1.Height / 2) + 2000 * Sin(i / (Label3 - 3) * 2 * 3.14)
- X2 = (Image1.Left + Image1.Width / 2) + 2300 * Cos(i / (Label3 - 3) * 2 * 3.14)
- Y2 = (Image1.Top + Image1.Height / 2) + 2300 * Sin(i / (Label3 - 3) * 2 * 3.14)
- Line (X1, Y1)-(X2, Y2), vbRed
- Me.Circle (X2, Y2), 200, vbRed
- Me.FontSize = 16
- Print i + 3
- Next
- End Sub
- '第四題,搜尋並反白
- Private Sub Command4_Click()
- Text2.SetFocus
- p = InStr(p, Text2, Text1)
- Print p
- If p = 0 Then
- Print "not found"
- p = 1
- Else
- Text2.SelStart = p - 1
- Text2.SelLength = Len(Text1)
- p = p + 1
- End If
- End Sub
- Private Sub Form_Load()
- p = 1
- End Sub
Add Comment
Please, Sign In to add comment