Advertisement
Tony041010

凱薩密碼系統

Jul 14th, 2021 (edited)
436
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Private Sub Command1_Click()
  2. '第一題,加密後放text2
  3.    Text2 = ""
  4.     For i = 1 To Len(Text1)
  5.         Text2 = Text2 & Chr(Asc(Mid(Text1, i, 1)) + Text4)
  6.     Next
  7. End Sub
  8.  
  9. Private Sub Command2_Click()
  10. '第二題,解密後放text3
  11.    Text3 = ""
  12.     For i = 1 To Len(Text2)
  13.         Text3 = Text3 & Chr(Asc(Mid(Text2, i, 1)) - Text4)
  14.     Next
  15. End Sub
  16.  
  17. Private Sub Command3_Click()
  18. '第三題,解密後放text6
  19.    n = -10
  20.     Text6 = ""
  21.     For i = 1 To Len(Text5)
  22.         Text6 = Text6 & Chr(Asc(Mid(Text5, i, 1)) + n)
  23.     Next
  24. End Sub
  25.  
  26. Private Sub Command4_Click()
  27. '第四題,轉盤解碼
  28.    Timer1.Interval = 800
  29.     Label2 = 26
  30. End Sub
  31.  
  32. Private Sub Timer1_Timer()
  33.     Me.Cls  '清除form1上面的所有作畫
  34.    
  35.     'cos(n),n的值由0-2PI
  36.    '***********下面的cos(0) sin(0)請參考講義改寫她才會轉動*************
  37.    x = (Image1.Left + Image1.Width / 2) + 2800 * Cos(Label2 * 2 / 53 * 3.14)
  38.     y = (Image1.Top + Image1.Height / 2) + 2800 * Sin(Label2 * 2 / 53 * 3.14)
  39.     '*******************************************************************
  40.    
  41.     '畫線,從中心點到上述算出的角度座標
  42.    Line ((Image1.Left + Image1.Width / 2), (Image1.Top + Image1.Height / 2))-(x, y), vbRed
  43.  
  44.     '*********第四題,解碼並用instr檢查是否正確
  45.    Text6 = ""
  46.     For i = 1 To Len(Text5)
  47.     Text6 = Text6 & Chr(Asc(Mid(Text5, i, 1)) - Label2)
  48.     Next
  49.     If InStr(Text6, Text7) Then
  50.     MsgBox Label2
  51.     Timer1.Interval = 0
  52.     Else
  53.     Label2 = Label2 - 1
  54.     End If
  55.    
  56. End Sub
  57.  
  58.  
Advertisement
RAW Paste Data Copied
Advertisement