Programas En Visual Basic Sencillos
Enviado por callita • 15 de Febrero de 2012 • 2.563 Palabras (11 Páginas) • 1.369 Visitas
COMO CAMBIAR LA IMAGEN DE FONDO DEL FORMULARIO
Public Class fondo
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.BackgroundImage = My.Resources.amor
End Sub
COMO CAMBIAR EL COLOR DE FONDO, LA VISIBILIDAD, Y AGREGAR TEXTO DEL CONTROL
Public Class Form1
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox2.BackColor = Color.Pink /Color de fondo/
TextBox2.Text = "saludo 2" /agregar texto al control/
caja3.Visible = True /propiedad visible del control/
End Sub
Private Sub salir_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles salir.Click
End
End Sub
COMO CREAR FUNCIONES Y AGREGAR AUDIO
Public Class Saludo
Sub saludo1()
TextBox1.BackColor = Color.DarkViolet
TextBox1.Text = "Hola"
Button2.Enabled = True
Button1.Enabled = False
My.Computer.Audio.Play(My.Resources.ringin, AudioPlayMode.Background)
End Sub
Sub saludo2()
TextBox1.BackColor = Color.DarkViolet
TextBox1.Text = "Suerte te cuidas"
Button2.Enabled = False
Button1.Enabled = True
My.Computer.Audio.Play(My.Resources.Apagado_de_Windows_XP,AudioPlayMode.Background)’para agregar audio’
Me.BackgroundImage = My.Resources.J0384885
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
saludo1() /para llamar la función/
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
saludo2()
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub
End Class
TOTALIZAR CON CHECKBOX
Dim total As Integer
Const camiseta = 25000
Const pantalon = 30000
Const medias = 7000
Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged
If (CheckBox1.Checked = True) Then
total += camiseta
Label2.Text = total
PictureBox1.Visible = True
Else
total -= camiseta
Label2.Text = total
PictureBox1.Visible = False
End If
End Sub
Private Sub CheckBox2_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox2.CheckedChanged
If (CheckBox2.Checked = True) Then
total += pantalon
Label2.Text = total
PictureBox2.Visible = True
Else
total -= pantalon
Label2.Text = total
PictureBox2.Visible = False
End If
End Sub
CONVERSION DE HORAS MINUTOS Y SEGUNDOS
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If (TextBox2.Text = "" And TextBox3.Text = "") Then
TextBox2.Text = Val(TextBox1.Text) * 60
TextBox3.Text = Val(TextBox1.Text) * 3600
ElseIf (TextBox1.Text = "" And TextBox3.Text = "") Then
TextBox1.Text = Val(TextBox2.Text) / 60
TextBox3.Text = Val(TextBox2.Text) * 60
ElseIf (TextBox1.Text = "" And TextBox2.Text = "") Then
TextBox1.Text = Val(TextBox3.Text) / 3600
TextBox2.Text = Val(TextBox3.Text) / 60
End If
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
End Sub
Private Sub TextBox3_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles TextBox3.KeyPress
If Char.IsDigit(e.KeyChar) Then
e.Handled = False
ElseIf Char.IsControl(e.KeyChar) Then
e.Handled = False
Else
MsgBox("¡solo se aceptan números!")
e.Handled = True
End If
End Sub
End Class
CONVERSOR DE TEMPERATURA
Public Class Form1
Dim grados As Double
Private Sub VScrollBar1_Scroll(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ScrollEventArgs) Handles VScrollBar1.Scroll
TextBox1.Text = VScrollBar1.Value
grados = 1.8 * VScrollBar1.Value + 32
TextBox2.Text = grados
If VScrollBar1.Value = 91 Then
MsgBox("llego al limite mas bajo de la conversión")
VScrollBar1.Value = 89
ElseIf VScrollBar1.Value = 10 Then
MsgBox("llego al limite mas bajo de la conversión")
VScrollBar1.Value = 12
End If
End Sub
CAMBIAR EFECTO, TAMAÑO, COLOR Y TIPO DE FUENTE O LETRA
Private _fnt As Font
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)Handles MyBase.Load
_fnt = TextBox1.Font
_fnt = New Font("Mistral", _fnt.Size, _fnt.Style, _fnt.Unit, _fnt.GdiCharSet)
_fnt = New Font(_fnt.FontFamily, 40, _fnt.Style, _fnt.Unit, _fnt.GdiCharSet)
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
TextBox1.Font = _fnt
TextBox1.Font = _fnt
End Sub
Este codigo es para que empiece a escribir con este tipo de fuente y en este tamaño
...