Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Oscilloscopio - Trigonometria.frm

Trigonometria.frm

Caricato da: Antometal
Scarica il programma completo

  1. Option Explicit
  2. Const Pi As Double = 3.14159
  3. Const MinX As Integer = -1000
  4. Const MaxX As Integer = 5000
  5. Const MaxY As Integer = 1000
  6. Const MinY As Integer = -1000
  7. Const Unit As Integer = 1000
  8. Dim Col(4) As ColorConstants
  9. Dim Spe(4) As Integer
  10.  
  11. Private Sub Controllo(Oggetto As TextBox)
  12.     If Oggetto <> "" Then
  13.             If IsNumeric(Oggetto) = False Then GoTo NoNum
  14.             If Oggetto < 0 Or Oggetto > 10000000 Then GoTo NnAccettabile
  15.         Oggetto.SelStart = Len(Oggetto)
  16.     End If
  17.  
  18. Exit Sub
  19. NoNum:
  20. MsgBox "Errore, tipo non corrispondente", vbCritical
  21. Oggetto.Text = ""
  22. Oggetto.SetFocus
  23. Exit Sub
  24. NnAccettabile:
  25. MsgBox "Errore,inserisci un numero maggiore o uguale a 0 e minore o ugale a 10000000", vbExclamation
  26. Oggetto.SelStart = 0
  27. Oggetto.SelLength = Len(Oggetto)
  28. Oggetto.SetFocus
  29. End Sub
  30.  
  31. Private Sub DisegnaOnde()
  32. On Error Resume Next
  33. Dim i, j As Integer
  34. Pic.Refresh
  35.     For i = MinX To MaxX
  36.         Pic.DrawWidth = Spe(1)
  37.             If chkSCTA(1).Value = 1 Then Pic.PSet (i, txtAlt(1) / 1000 * Cos(i * Pi / 180 * 1 / txtPeriodo(1)) * Unit), Col(1)
  38.         Pic.DrawWidth = Spe(2)
  39.             If chkSCTA(2).Value = 1 Then Pic.PSet (i, txtAlt(2) / 1000 * Sin(i * Pi / 180 * 1 / txtPeriodo(2)) * Unit), Col(2)
  40.         Pic.DrawWidth = Spe(3)
  41.             If chkSCTA(3).Value = 1 Then Pic.PSet (i, txtAlt(3) / 1000 * Tan(i * Pi / 180 * 1 / txtPeriodo(3)) * Unit), Col(3)
  42.         Pic.DrawWidth = Spe(4)
  43.             If chkSCTA(4).Value = 1 Then Pic.PSet (i, txtAlt(4) / 1000 / Tan(i * Pi / 180 * 1 / txtPeriodo(4)) * Unit), Col(4)
  44.     Next i
  45. End Sub
  46.  
  47. Private Sub chkAssi_Click()
  48. DisegnaAssi
  49. End Sub
  50.  
  51. Private Sub DisegnaAssi()
  52.     If chkSCTA(0).Value = 1 Then
  53.         Pic.DrawWidth = Spe(0)
  54.         Pic.Line (0, MaxY)-(0, MinY), Col(0)
  55.         Pic.Line (MinX, 0)-(MaxX, 0), Col(0)
  56.     End If
  57. End Sub
  58.  
  59. Private Sub chkSCTA_Click(Index As Integer)
  60. DisegnaOnde
  61. DisegnaAssi
  62. End Sub
  63.  
  64. Private Sub ColSCTA_Click(Index As Integer)
  65. CDialog.ShowColor
  66. Col(Index) = CDialog.Color
  67. chkSCTA_Click (Index)
  68. End Sub
  69.  
  70. Private Sub ColSfondo_Click()
  71. CDialog.ShowColor
  72. Pic.BackColor = CDialog.Color
  73. End Sub
  74.  
  75. Private Sub Form_Load()
  76. Pic.Scale (MinX, MaxY)-(MaxX, MinY)
  77. Col(0) = vbWhite
  78. Col(1) = vbGreen
  79. Col(2) = vbBlue
  80. Col(3) = vbRed
  81. Col(4) = vbYellow
  82. Spe(0) = 1
  83. Spe(1) = 1
  84. Spe(2) = 1
  85. Spe(3) = 1
  86. Spe(4) = 1
  87. End Sub
  88.  
  89. Private Sub SpeSCTA_Click(Index As Integer)
  90. Spe(Index) = InputBox("Inserisci lo sessore del trato della funzione " & SpeSCTA(Index).Caption & vbCrLf & "Inserisci un numero intero compreso tra 1 e 20", "Trigonometria", Pic.DrawWidth)
  91.     If IsNumeric(Spe(Index)) = False Then GoTo NoNum
  92.     If Spe(Index) < 1 Or Spe(Index) > 20 Then GoTo Fuori
  93. chkSCTA_Click (Index)
  94.  
  95. Exit Sub
  96. NoNum:
  97. MsgBox "Errore, inserisci valore numerico", vbCritical, "Tipo non corrispondente"
  98. Exit Sub
  99. Fuori:
  100. MsgBox "Errore, insrisci un numero intero compreso tra 1 e 20", vbExclamation, "Trigonometria"
  101. End Sub
  102.  
  103. Private Sub txtAlt_Change(Index As Integer)
  104. Controllo txtAlt(Index)
  105. chkSCTA_Click (Index)
  106. End Sub
  107.  
  108. Private Sub txtPeriodo_Change(Index As Integer)
  109. Controllo txtPeriodo(Index)
  110. chkSCTA_Click (Index)
  111. End Sub