VERIFICAR QUAL O MAIOR NUMERO EM VARIOS TEXTBOX
Pessoal como eu posso fazer para que me mostre o maior numero entre varios textbox, ex:
tenho 3 "textbox", um abaixo do outro, Textbox1 = 1
Textbox2 = 5
Textbox3 = 10
resultado Textbox4 = 10
é como se fosse a formula MAXIMO do Excel.
Agradeço desde já
Raul Alves
tenho 3 "textbox", um abaixo do outro, Textbox1 = 1
Textbox2 = 5
Textbox3 = 10
resultado Textbox4 = 10
é como se fosse a formula MAXIMO do Excel.
Agradeço desde já
Raul Alves
Código sob encomenda... Fresquinho!!!
1- Criei 4 textboxes com mesmo nome e indices distintos
2- Criei um command button
Coloque este código no botão.
Testa aeh
1- Criei 4 textboxes com mesmo nome e indices distintos
2- Criei um command button
Coloque este código no botão.
Private Sub Command1_Click()
Dim x, MaiorNum As Integer
MaiorNum = 0
'3 é (número de textboxes - 1) comeca em 0, 1, 2, 3
'e assim sucessivamente
For x = 0 To 3
If MaiorNum < Text1(x).Text Then
MaiorNum = Text1(x).Text
End If
Next
MsgBox MaiorNum
End Sub
Testa aeh
Detalhe...
Se for trabalhar com numeros grandes, declare a variável "MAIORNUM" como Long ou Double...
Assim:
Se for trabalhar com numeros grandes, declare a variável "MAIORNUM" como Long ou Double...
Assim:
Dim x As Integer
Dim MaiorNum As Double
Se vc não quiser fazer indice use If normalmente
If (Text1.Text > Text2.Text) And (Text1.Text > Text3.Text) Then
Text4.Text = Text1.text
Else
....
If (Text1.Text > Text2.Text) And (Text1.Text > Text3.Text) Then
Text4.Text = Text1.text
Else
....
Tópico encerrado , respostas não são mais permitidas