Bueno, estoy haciendo un trabajito para programacion y me kede estancado..
El trabajo consiste en hacer un programita con Visual-Basic que tu le des 4 numeros, te los ordene de mayor a menor y de menor a mayor, que solo puedeas poner numeros (que no puedas pner letras en los text) y que te deje poner un "-" de lante de cada numero y una sola "," o "." entre el numero.. Podeis ayudarme?
Os paso el codigo del programa..
Dim a As Double
Dim b As Double
Dim c As Double
Dim d As Double
Dim t As Double
Private Sub Text1_Change()
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
d = Val(Text4.Text)
If a < d Then
t = a
a = d
d = t
End If
If b < d Then
t = b
b = d
d = t
End If
If c < d Then
t = c
c = d
d = t
End If
If a < c Then
t = a
a = c
c = t
End If
If b < c Then
t = b
b = c
c = t
End If
If a < b Then
t = a
a = b
b = t
End If
Label1.Caption = a
Label2.Caption = b
Label3.Caption = c
Label4.Caption = d
Label5.Caption = d
Label6.Caption = c
Label7.Caption = b
Label8.Caption = a
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Then Exit Sub
If KeyAscii < 44 Or KeyAscii > 57 Then
KeyAscii = 0
End If
End Sub
Private Sub Text2_Change()
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
d = Val(Text4.Text)
If a < d Then
t = a
a = d
d = t
End If
If b < d Then
t = b
b = d
d = t
End If
If c < d Then
t = c
c = d
d = t
End If
If a < c Then
t = a
a = c
c = t
End If
If b < c Then
t = b
b = c
c = t
End If
If a < b Then
t = a
a = b
b = t
End If
Label1.Caption = a
Label2.Caption = b
Label3.Caption = c
Label4.Caption = d
Label5.Caption = d
Label6.Caption = c
Label7.Caption = b
Label8.Caption = a
End Sub
Private Sub Text2_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Then Exit Sub
If KeyAscii < 44 Or KeyAscii > 57 Then
KeyAscii = 0
End If
End Sub
Private Sub Text3_Change()
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
d = Val(Text4.Text)
If a < d Then
t = a
a = d
d = t
End If
If b < d Then
t = b
b = d
d = t
End If
If c < d Then
t = c
c = d
d = t
End If
If a < c Then
t = a
a = c
c = t
End If
If b < c Then
t = b
b = c
c = t
End If
If a < b Then
t = a
a = b
b = t
End If
Label1.Caption = a
Label2.Caption = b
Label3.Caption = c
Label4.Caption = d
Label5.Caption = d
Label6.Caption = c
Label7.Caption = b
Label8.Caption = a
End Sub
Private Sub Text3_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Then Exit Sub
If KeyAscii < 44 Or KeyAscii > 57 Then
KeyAscii = 0
End If
End Sub
Private Sub Text4_Change()
a = Val(Text1.Text)
b = Val(Text2.Text)
c = Val(Text3.Text)
d = Val(Text4.Text)
If a < d Then
t = a
a = d
d = t
End If
If b < d Then
t = b
b = d
d = t
End If
If c < d Then
t = c
c = d
d = t
End If
If a < c Then
t = a
a = c
c = t
End If
If b < c Then
t = b
b = c
c = t
End If
If a < b Then
t = a
a = b
b = t
End If
Label1.Caption = a
Label2.Caption = b
Label3.Caption = c
Label4.Caption = d
Label5.Caption = d
Label6.Caption = c
Label7.Caption = b
Label8.Caption = a
End Sub
Private Sub Text4_KeyPress(KeyAscii As Integer)
If KeyAscii = 8 Then Exit Sub
If KeyAscii < 44 Or KeyAscii > 57 Then
KeyAscii = 0
End If
End Sub
En este codigo me deja poner el "-" donde me salga de los co**** y cuantas "," y "." quiera, y necesito restrigirlo a: un "-" delante del numero y una sola "," o "."
Gracias por adelantado