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
Potenze di numeri immaginari - Potenze di numeri immaginari.frm

Potenze di numeri immaginari.frm

Caricato da: Antometal
Scarica il programma completo

  1. Option Explicit
  2. Public RipristinoEsponente As String
  3. Public RipristinoReale As String
  4. Public RipristinoImmaginario As String
  5. Public XS As Integer
  6. Public YS As Integer
  7. Const Pi As Double = 3.141592653589
  8.  
  9. Private Sub Seleziona(Oggetto As TextBox)
  10. Oggetto.SelStart = 0
  11. Oggetto.SelLength = Len(Oggetto)
  12. Oggetto.SetFocus
  13. End Sub
  14.  
  15. Private Sub Controllo(Oggetto As TextBox, Ripristino As String)
  16. Dim I As Integer
  17. Oggetto = Val(Oggetto)
  18.     If Oggetto = 0 Then Seleziona Oggetto
  19.     For I = 1 To Len(Oggetto)
  20.             If (Asc(Mid(Oggetto, I, 1)) < 48 Or Asc(Mid(Oggetto, I, 1)) > 59) Or (Oggetto = 0 And Oggetto.TabIndex = 2) Then Oggetto.Text = Ripristino
  21.         Ripristino = Abs(Oggetto.Text)
  22.     Next I
  23. End Sub
  24.  
  25. Private Function Segno(Index As Integer) As Integer
  26.     If Index = 0 Then Segno = -1
  27.     If Index = 1 Then Segno = 1
  28. End Function
  29.  
  30. Private Function GPS(ByVal Gradi As Double) As String
  31. Dim G As Double
  32. Dim P As Double
  33. Dim S As Double
  34.     Do Until Gradi < 360
  35.         Gradi = Gradi - 360
  36.     Loop
  37. G = Int(Gradi)
  38. Gradi = (Gradi - G) * 100
  39. Gradi = Gradi * 3 / 5
  40. P = Int(Gradi)
  41. Gradi = (Gradi - P) * 100
  42. Gradi = Gradi * 3 / 5
  43. S = Int(Gradi)
  44. GPS = G & "° " & P & "' " & S & """"
  45. End Function
  46.  
  47. Private Sub cmdRisultati_Click()
  48. Dim Grado As Integer
  49. Dim P As Integer
  50.     If txtReale = 0 Or txtImmaginario = 0 Then
  51.             If txtReale = 0 And optSImmaginario(0).Value = True Then Grado = 270
  52.             If txtReale = 0 And optSImmaginario(1).Value = True Then Grado = 90
  53.             If txtImmaginario = 0 And optSReale(0).Value = True Then Grado = 180
  54.             If txtImmaginario = 0 And optSReale(1).Value = True Then Grado = 0
  55.     Else
  56.         Grado = Atn(YS * txtImmaginario / XS * txtReale) * 180 / Pi
  57.             If YS = -1 Then Grado = Grado + 180
  58.     End If
  59. P = Sqr(txtReale ^ 2 + txtImmaginario ^ 2)
  60. txtRisultato.Text = "(Z)^" & txtEsponente & "=" & String(5, " ") & P & "*(cos " & GPS(Grado * txtEsponente) & " + i*sin " & GPS(Grado * txtEsponente) & ")=" & String(5, " ") & P * Round(Cos(Grado * txtEsponente * Pi / 180), 4) & " + " & Round(Sin(Grado * txtEsponente * Pi / 180), 4) & "i"
  61. End Sub
  62.  
  63. Private Sub Form_Load()
  64. XS = 1
  65. YS = 1
  66. RipristinoReale = txtReale
  67. RipristinoImmaginario = txtImmaginario
  68. RipristinoEsponente = txtEsponente
  69. End Sub
  70.  
  71. Private Sub optSImmaginario_Click(Index As Integer)
  72. YS = Segno(Index)
  73. End Sub
  74.  
  75. Private Sub optSReale_Click(Index As Integer)
  76. XS = Segno(Index)
  77. End Sub
  78.  
  79. Private Sub txtEsponente_Change()
  80. Controllo txtEsponente, RipristinoEsponente
  81. End Sub
  82.  
  83. Private Sub txtEsponente_GotFocus()
  84. Seleziona txtEsponente
  85. End Sub
  86.  
  87. Private Sub txtImmaginario_Change()
  88. Controllo txtImmaginario, RipristinoImmaginario
  89. End Sub
  90.  
  91. Private Sub txtImmaginario_GotFocus()
  92. Seleziona txtImmaginario
  93. End Sub
  94.  
  95. Private Sub txtReale_Change()
  96. Controllo txtReale, RipristinoReale
  97. End Sub
  98.  
  99. Private Sub txtReale_GotFocus()
  100. Seleziona txtReale
  101. End Sub
  102.  
  103. Private Sub txtRisultato_DblClick()
  104. Clipboard.Clear
  105. Clipboard.SetText txtRisultato
  106. End Sub