Autor Tópico: Visual basic...............Temperaturas...........  (Lida 1150 vezes)

Offline Kacetada

  • Newbie
  • *
  • Mensagens: 0
  • Karma: +0/-0
    • Ver Perfil
Visual basic...............Temperaturas...........
« em: Fevereiro 26, 2006, 12:52:09 am »
Dim temp(1 To 12) As Single

Private Sub Command1_Click()
For i = 1 To 12
temp(i) = InputBox(\\"introduza a temperatura do \\" & i & \\" mes\\")
Next
For i = 1 To 12
Picture1.Print temp(i)
Next
End Sub

Private Sub Command2_Click()
For i = 1 To 12
soma = soma + temp(i)
Next
media = soma / 12
MsgBox \\"a media anual é \\" & media & \\"\\"

End Sub

Private Sub Command3_Click()
temp(1) = Max
mes = 1
For i = 2 To 12
    If temp(i) > Max Then
    Max = temp(i)
    mes = i
    End If
Next
MsgBox (\\"a temperatura mais alta foi de \\" & Max & \\" e ocorreu no mes \\" & mes & \\"\\")
End Sub

Private Sub Command4_Click()
soma = 0
For i = 1 To 12
If temp(i) < 0 Then
soma = soma + 1
End If
Next
MsgBox \\"o numero de temperaturas negativas foram \\" & soma & \\"\\"
End Sub

Private Sub Command5_Click()
Dim dif(1 To 12) As Single
temp_int = InputBox(\\"introduza uma temperatura\\")
For i = 1 To 12
If temp(i) < temp_int And temp(i) > 0 Then
dif(i) = temo_int - temp(i)
End If
If temp(i) < temp_int And temp(i) < 0 And temp_int > 0 Then
dif(i) = temp(i) - temp_int
End If
If temp(i) < temp_int And temp(i) < 0 And temp_int < 0 Then
dif(i) = temp(i) + temp_int
End If
If temp(i) > temp_int And temp_int > 0 Then
dif(i) = temp(i) - temp_int
End If
If temp(i) > temp_int And temp_int < 0 Then
dif(i) = temp(i) + temp_int
End If
If temp(i) = temp_int Then
dif(i) = 0
End If
Next
prox = dif(1)
mes = 1
For i = 2 To 12
If prox > dif(i) Then
prox = dif(i)
mes = i
End If
Next
MsgBox \\"a temperatura mais proxima com a que introduziu ocorreu no mes\\" & mes & \\"\\"
End Sub

 

Sitemap 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