You are on page 1of 4

Evento enter en un textbox:

Private Sub TextBox1_KeyDown(sender As Object, e As KeyEventArgs) Handles


TextBox1.KeyDown
If e.KeyCode = Keys.Enter Then
Label1.Text = TextBox1.Text * 2
End If
End Sub

1. Picture box
Cambiar el picture box de colorres con aventos mousemove,,, mouseleave.. form1_click
Public Class Form1

Private Sub PictureBox1_MouseMove(sender As Object, e As MouseEventArgs) Handles


PictureBox1.MouseMove
PictureBox1.BackColor = Color.Green
End Sub

Private Sub PictureBox1_MouseLeave(sender As Object, e As EventArgs) Handles


PictureBox1.MouseLeave
PictureBox1.BackColor = Color.Yellow
End Sub

Private Sub Form1_Click(sender As Object, e As EventArgs) Handles MyBase.Click


PictureBox1.BackColor = Color.Blue

End Sub
End Class.
2. If

Public Class Form1


Private Sub Button1_Click(sender As Object, e As EventArgs) Handles
Button1.Click
If TextBox1.Text >= 0 Then
Label2.Text = " el nro es positivo"
Else
Label2.Text = " el nro es impar"
End If
End Sub
End Class

If con and or not


and
Public Class Form1

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles


Button1.Click
If TextBox1.Text = TextBox2.Text And TextBox1.Text = TextBox3.Text
Then
Label4.Text = "Los 3 nros son iguales"
Else
Label4.Text = "son diferentes"
End If
End Sub
End Class

OR
Public Class Form1

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles


Button1.Click
If TextBox1.Text = "a" Or TextBox1.Text = "e" Or TextBox1.Text = "i" Or
TextBox1.Text = "o" Or TextBox1.Text = "u" Then
Label2.Text = "Es una Vocal"
Else
Label2.Text = "Es consonante"
End If
End Sub
End Class

Es par o impar
Public Class Form1

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles


Button1.Click

If TextBox1.Text Mod 2 = 0 Then

Label2.Text = "es par"


Else
Label2.Text = "es inpar"
End If

End Sub
End Class

Mostrar mayor y menor

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click


Dim x, y As Integer
x = TextBox1.Text
y = TextBox2.Text
If x > y Then
Label3.Text = "el mayor es :" & Str(x)
Label4.Text = " menor es" & Str(y)
End If
If x < y Then
Label3.Text = "el menor es :" & Str(x)
Label4.Text = " El mayor es" & Str(y)

End If
End Sub

Ingresar 3 numeros y decir cuabtos son + y –

Public Class Form3

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles


Button1.Click
Dim x, y, z, pos, neg As Double
x = TextBox1.Text
y = TextBox2.Text
z = TextBox3.Text
pos = 0
neg = 0
If x >= 0 Then
pos = pos + 1
Else
neg = neg + 1

End If
If y >= 0 Then
pos = pos + 1
Else
neg = neg + 1
End If
If z >= 0 Then
pos = pos + 1
Else
neg = neg + 1

End If
Label1.Text = Str(pos) + " numeros positivos" + Str(neg) + " numeros
negativos"
End Sub
End Class

You might also like