epelpad

Visual Basic 2010

Visual Basic 2010



Números Pares e Impares


Visual Basic 2010



Public Class Form1
Dim N As Integer
Dim C As Integer
Dim Suma As Integer
Dim ) As Integer
Dim I As Integer

Private Sub txtCantidad_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles txtCantidad.KeyPress
If e.KeyChar = Convert.ToChar(Keys.Return) Then
N = Val(txtCantidad.Text)
txtCantidad.Enabled = False
txtNum.Enabled = True
txtNum.Focus()
End If
End Sub


Private Sub txtNum_KeyPress(sender As Object, e As System.Windows.Forms.KeyPressEventArgs) Handles txtNum.KeyPress
ReDim Preserve N)
If e.KeyChar = Convert.ToChar(Keys.Return) Then
C = C + 1
C) = Val(txtNum.Text)
lblCantidad.Text = C
txtNum.Clear()
End If
If C = N Then
For I = 1 To N
If I) Mod 2 = 0 Then
lstPares.Items.Add(I))
Else
lstImpares.Items.Add(I))
End If
Next
txtNum.Enabled = False

End If

End Sub





Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
txtCantidad.Clear()
txtNum.Clear()
txtCantidad.Enabled = True
txtNum.Enabled = False
txtCantidad.Focus()
lstImpares.Items.Clear()
lstPares.Items.Clear()
For H = 1 To N Step 1
H) = 0
C = 0
Next

End Sub

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

Calculadora


Visual Studio


Public Class Form1
Dim op As String
Dim a, b, resultado As Double
Dim c As Double


Private Sub TextBox1_TextChanged(sender As System.Object, e As System.EventArgs) Handles Text1.TextChanged

End Sub

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
If c = True Then
Text1.Text = ""
End If
Text1.Text = Text1.Text + "7"
c = False
End Sub

Private Sub Button7_Click(sender As System.Object, e As System.EventArgs) Handles Button7.Click
If c = True Then
Text1.Text = ""
End If
Text1.Text = Text1.Text + "8"
c = False
End Sub

Private Sub Button9_Click(sender As System.Object, e As System.EventArgs) Handles Button9.Click
If c = True Then
Text1.Text = ""
End If
Text1.Text = Text1.Text + "9"
c = False
End Sub

Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click
If c = True Then
Text1.Text = ""
End If
Text1.Text = Text1.Text + "4"
c = False
End Sub

Private Sub Button6_Click(sender As System.Object, e As System.EventArgs) Handles Button6.Click
If c = True Then
Text1.Text = ""
End If
Text1.Text = Text1.Text + "5"
c = False
End Sub

Private Sub Button5_Click(sender As System.Object, e As System.EventArgs) Handles Button5.Click
If c = True Then
Text1.Text = ""
End If
Text1.Text = Text1.Text + "6"
c = False
End Sub

Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
If c = True Then
Text1.Text = ""
End If
Text1.Text = Text1.Text + "1"
c = False
End Sub

Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
If c = True Then
Text1.Text = ""
End If
Text1.Text = Text1.Text + "2"
c = False
End Sub

Private Sub Button8_Click(sender As System.Object, e As System.EventArgs) Handles Button8.Click
If c = True Then
Text1.Text = ""
End If
Text1.Text = Text1.Text + "3"
c = False
End Sub

Private Sub Button10_Click(sender As System.Object, e As System.EventArgs) Handles Button10.Click
If c = True Then
Text1.Text = ""
End If
Text1.Text = Text1.Text + "0"
c = False
End Sub

Private Sub Button12_Click(sender As System.Object, e As System.EventArgs) Handles Button12.Click
a = Text1.Text
Text1.Text = ""
op = "Suma"
End Sub

Private Sub Button14_Click(sender As System.Object, e As System.EventArgs) Handles Button14.Click
a = Text1.Text
Text1.Text = ""
op = "Resta"
End Sub

Private Sub Button13_Click(sender As System.Object, e As System.EventArgs) Handles Button13.Click
a = Text1.Text
Text1.Text = ""
op = "Multiplicación"
End Sub

Private Sub Button15_Click(sender As System.Object, e As System.EventArgs) Handles Button15.Click
a = Text1.Text
Text1.Text = ""
op = "División"
End Sub

Private Sub Button16_Click(sender As System.Object, e As System.EventArgs) Handles Button16.Click
b = Val(Text1.Text)
Select Case op
Case "Suma"
resultado = a + b
Text1.Text = resultado
Case "Resta"
resultado = a - b
Text1.Text = resultado
Case "Multiplicación"
resultado = a * b
Text1.Text = resultado
Case "División"
resultado = a / b
Text1.Text = resultado



End Select
End Sub

Private Sub Button17_Click(sender As System.Object, e As System.EventArgs) Handles Button17.Click
Text1.Text = ""
End Sub
End Class

0 comentarios - Visual Basic 2010