0% found this document useful (0 votes)
39 views4 pages

Evento Enter en Un Textbox:: Private Sub As Object As Handles If Then End If End Sub

The document contains code examples demonstrating how to use events like KeyDown and MouseMove to trigger actions in Visual Basic forms and controls. Conditional logic is shown using If/Then statements to check values in textboxes and labels and perform different actions depending on the results. Examples also show how to check values, determine if numbers are even or odd, find the largest or smallest of two numbers, and count positive and negative values from user input.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
39 views4 pages

Evento Enter en Un Textbox:: Private Sub As Object As Handles If Then End If End Sub

The document contains code examples demonstrating how to use events like KeyDown and MouseMove to trigger actions in Visual Basic forms and controls. Conditional logic is shown using If/Then statements to check values in textboxes and labels and perform different actions depending on the results. Examples also show how to check values, determine if numbers are even or odd, find the largest or smallest of two numbers, and count positive and negative values from user input.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 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