Angulos

Anuncio
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
'=====================================================================
'// Programa ........................... Angulos.exe
'// Proyecto ........................... Prácticas de 1º BTO
'// Autor .............................. Jesús P. M. (zttsoft.com)
'// Fecha ............................. 13/06/2006
'// Modificación ....................... 13/06/2006
'=====================================================================
Option Explicit
' constante
Dim PI As Double
' convierte a radianes
Dim CRad As Double
' convierte a grados sexagesimales
Dim CGra As Double
Dim datGRA As Boolean
Dim datRAD As Boolean
Public Function GraMinSeg(Num As Double) As String
Dim sw As Double
Dim g As Double, m As Double, s As Double
g = Int(Num)
sw = (Num - g) * 60
m = Int(sw)
s = Int((sw - m) * 60)
GraMinSeg = Str(g) & "º " & Str(m) & "' " & Str(s) & "''"
End Function
Private Sub Command1_Click()
End
End Sub
Private Sub Command2_Click(Index As Integer)
Form2.Show 1
End Sub
Private Sub Form_Load()
PI = 4 * Atn(1)
CRad = PI / 180
CGra = 180 / PI
End Sub
Private Sub txt_Angulo_Change(Index As Integer)
Dim sw1 As Double, sw2 As Double
If IsNumeric(txt_Angulo(Index).Text) Then
Select Case Index
Case 0 And datGRA = True
lbl_GMS(0).Caption = Int(txt_Angulo(0).Text)
sw1 = (txt_Angulo(0).Text - Int(txt_Angulo(0).Text)) * 60
lbl_GMS(1).Caption = Int(sw1)
sw2 = (sw1 - Int(sw1)) * 60
lbl_GMS(2).Caption = Int(sw2)
txt_Angulo(1).Text = Round(txt_Angulo(0).Text * CRad, 4)
Case 1 And datRAD = True
txt_Angulo(0).Text = Round(txt_Angulo(1).Text * CGra, 4)
End Select
Else
txt_Angulo(0).Text = 0
txt_Angulo(1).Text = 0
txt_Angulo(Index).SelStart = 0
txt_Angulo(Index).SelLength = Len(txt_Angulo(Index).Text)
End If
End Sub
Private Sub txt_Angulo_GotFocus(Index As Integer)
txt_Angulo(Index).SelStart = 0
txt_Angulo(Index).SelLength = Len(txt_Angulo(Index).Text)
If Index = 0 Then
datGRA = True
datRAD = False
Else
datGRA = False
datRAD = True
End If
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
End Sub
Private Sub txt_Angulo_KeyPress(Index As Integer, KeyAscii As Integer)
' permitir tecla borrar (BACKSPACE)
If KeyAscii <> 8 Then
If KeyAscii = 46 Then KeyAscii = 44 ' cambia punto por coma
If KeyAscii = 45 Then KeyAscii = 0 ' Solo números positivos
If Not IsNumeric("0" & txt_Angulo(Index).Text & Chr(KeyAscii)) Then
KeyAscii = 0
End If
End If
' se pulsa Intro
If KeyAscii = 13 Then
KeyAscii = 0
' quita el Beep del intro
'SendKeys "{TAB}"
' pasa el foco al siguiente objeto
End If
End Sub
'/// FINAL DE CÓDIGO ==============================================
Descargar