Public Class Form1
Private Sub CmdCalcula_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdCalcula.Click
Dim X, Y As Integer
X = 0
For X = 1 To 10
If X > 2 And X > 5 Then
Y = X + Y
End If
Next
txtResult.Text = Y
End Sub
End Class
Resultado: 7
*********************************************************************
Public Class Form1
Private Sub CmdCalcula_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdCalcula.Click
Dim X, Y As Integer
X = 5
For X = 1 To 3
X = X * Y - 2
Next
txtResult.Text = X
End Sub
End Class
Resultado: 10
***************************************************************
Public Class Form1
Private Sub CmdCalcula_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdCalcula.Click
Dim X, Y, R As Integer
X = 0
For Y = 0 To 10
R = Y Mod 2
If R > 0 Then
X = X + Y
End If
Next
txtResult.Text = X
End Sub
End Class
Resultado: 25
***************************************************************
Public Class Form1
Private Sub CmdCalcula_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdCalcula.Click
Dim X, Y, Z As Integer
X = 2
Z = X + 4 / 2
Y = X * 2 ^ Z
X = (Y + Z) / 2
Z = Y - X + Z - 2
Y = Y - 3 - Z / 2
X = Y - Z
If Z > 16 Then
X = Y + Z - Y
Else
X = Y - Z + X
End If
MsgBox(X)
MsgBox(Y)
MsgBox(Z)
End Sub
End Class
Resultado: X=10, Y= 21, Z= 16
***************************************************************
Public Class Form1
Private Sub CmdCalcula_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdCalcula.Click
Dim X, Y, Z As Integer
X = 4
Y = 10
Z = X - Y / 5
Do While Y > X
Y = Y - Z
Z = Z + 1
Loop
MsgBox(Y)
MsgBox(Z)
End Sub
End Class
Resposta: Y=1, Z=5
***************************************************************
Public Class Form1
Private Sub CmdCalcula_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdCalcula.Click
Dim X, Y, Z As Integer
X = 15
Z = (X - 3) / 3
Y = Z * 2 ^ 2
X = Y + Z / 2
X = X - Y + Z
Y = Y - 3 - X / 2
X = X + Z - Y
MsgBox(X)
MsgBox(Y)
MsgBox(Z)
End Sub
End Class
Resultado: X=0, Y=10, Z=4
***************************************************************
Public Class Form1
Private Sub CmdCalcula_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdCalcula.Click
Dim X, Y, Z, R As Integer
X = 2
Y = 3
Z = 4
If X < Y And Z > X And Y < Z Then “Verdadeiro”
R = 3 + Z / X
End If
If Z < Y And Z < X Or Y = X Then “Falso”
R = X * Y - 1
End If
If X <> Y And X > Z Or Y > X Then “Verdadeiro”
R = Y / 3 + Z / 2 - 1
End If
MsgBox(R)
End Sub
End Class
Resposta: R=2
Nenhum comentário:
Postar um comentário
Surpreenda com o seu conhecimento...