lunes, 12 de noviembre de 2007

visual basic 6.0:AREA DEL CIRCULO

visual basic 6.0:AREA DEL CIRCULO

visual basic 6.0:CALCULADORA BASICA

visual basic 6.0:CALCULADORA BASICA

visual basic 6.0:CONVERTIDOR DE NUMEROS

visual basic 6.0:CONVERTIDOR DE NUMEROS

visual basic 6.0:CALCULADORA

visual basic 6.0:CALCULADORA

visual basic 6.0: CONVERTIDOR DE MONEDA

visual basic 6.0: CONVERTIDOR DE MONEDA

visual basic 6.0: PEDIDO DE COMIDAS

visual basic 6.0: PEDIDO DE COMIDAS

visual basic 6.0: COLORES Y POSICIONES

visual basic 6.0: COLORES Y POSICIONES

visual basic 6.0: SEMAFORO

visual basic 6.0: SEMAFORO

visual basic 6.0: CARROS Y SEMAFOROS

visual basic 6.0: CARROS Y SEMAFOROS

CARROS Y SEMAFOROS







CODIGO_______________________________________________________________
Private Sub Form_Load()
Shape1.Visible = False
Shape2.Visible = False
Shape3.Visible = False
Shape5.Visible = False
Shape6.Visible = False
Shape7.Visible = False
End Sub
Private Sub Timer1_Timer()


'activa el semaforo
Form2.Caption = Val(Form2.Caption) + 1
Shape1.Visible = True
Shape2.Visible = False
Shape3.Visible = False
If Form2.Caption > 5 Then
Shape1.Visible = False
Shape2.Visible = True
Shape3.Visible = False
If Form2.Caption > 10 Then
Shape1.Visible = False
Shape2.Visible = False
Shape3.Visible = True
If Form2.Caption > 15 Then
Shape1.Visible = False
Shape2.Visible = True
Shape3.Visible = False
If Form2.Caption > 20 Then
Shape1.Visible = True
Shape2.Visible = False
Shape3.Visible = False
Form2.Caption = "0"
End If
End If
End If
End If
End Sub
Private Sub Timer2_Timer()


'mueve el carro de derecha a izquierda
a.Caption = Val(a.Caption) + 1
If a.Caption > 10 Then
carro.Left = 500
If a.Caption > 11 Then
carro.Left = 1000
If a.Caption > 12 Then
carro.Left = 1500
If a.Caption > 13 Then
carro.Left = 2000
If a.Caption > 14 Then
carro.Left = 2500
If a.Caption > 15 Then
carro.Left = 3000
If a.Caption > 16 Then
carro.Left = 3500
If a.Caption > 17 Then
carro.Left = 4000
If a.Caption > 18 Then
carro.Left = 4500
If a.Caption > 19 Then
carro.Left = 5000
If a.Caption > 20 Then
carro.Left = 5500
If a.Caption > 21 Then
carro.Left = 6000
If a.Caption > 31 Then
carro.Left = 6500
If a.Caption > 32 Then
carro.Left = 7000
If a.Caption > 33 Then
carro.Left = 7500
If a.Caption > 34 Then
carro.Left = 8000
If a.Caption > 35 Then
carro.Left = 9000
If a.Caption > 36 Then
carro.Left = 10000
If a.Caption > 37 Then
carro.Left = 11000
If a.Caption > 38 Then
carro.Left = 12000
If a.Caption > 39 Then
a.Caption = "0"
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End Sub

Private Sub Timer3_Timer()


'activa el semaforo
Shape7.Visible = True
Shape6.Visible = False
Shape5.Visible = False
If Form2.Caption > 5 Then
Shape7.Visible = False
Shape6.Visible = True
Shape5.Visible = False
If Form2.Caption > 10 Then
Shape7.Visible = False
Shape6.Visible = False
Shape5.Visible = True
If Form2.Caption > 15 Then
Shape7.Visible = False
Shape6.Visible = True
Shape5.Visible = False

If Form2.Caption > 20 Then
Shape7.Visible = True
Shape6.Visible = False
Shape5.Visible = False
End If
End If
End If
End If

End Sub

Private Sub Timer4_Timer()


'mueve el carro de izquierda a derecha
b.Caption = Val(b.Caption) + 1
If b.Caption > 0 Then
carro1.Left = 12500
If b.Caption > 1 Then
carro1.Left = 12000
If b.Caption > 2 Then
carro1.Left = 11000
If b.Caption > 3 Then
carro1.Left = 10000
If b.Caption > 4 Then
carro1.Left = 9000
If b.Caption > 5 Then
carro1.Left = 8000
If b.Caption > 6 Then
carro1.Left = 7000
If b.Caption > 7 Then
carro1.Left = 6000
If b.Caption > 8 Then
carro1.Left = 5000
If b.Caption > 9 Then
carro1.Left = 4500
If b.Caption > 10 Then
carro1.Left = 4000
If b.Caption > 17 Then
carro1.Left = 3000
If b.Caption > 18 Then
carro1.Left = 2000
If b.Caption > 19 Then
carro1.Left = 1000
If b.Caption > 20 Then
carro1.Left = 1000
If b.Caption > 21 Then
carro1.Left = 500
If b.Caption > 22 Then
carro1.Left = 250
If b.Caption > 23 Then
carro1.Left = 100
b.Caption = "0"
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End If
End Sub

SEMAFORO



CODIGO_______________________________________________________________
Private Sub Form_Load()
'no permite ver los faroles del semaforo
Shape1.Visible = False
Shape2.Visible = False
Shape3.Visible = False
End Sub

Private Sub Timer1_Timer()
'cada vez que el valor del caption del formulario se cumpliran las siguientes condiciones
Form1.Caption = Val(Form1.Caption) + 1
If Form1.Caption > 0 Then
Shape1.Visible = True
Shape2.Visible = False
Shape3.Visible = False
If Form1.Caption > 5 Then
Shape1.Visible = False
Shape2.Visible = True
Shape3.Visible = False
If Form1.Caption > 10 Then
Shape1.Visible = False
Shape2.Visible = False
Shape3.Visible = True
If Form1.Caption > 15 Then
Shape1.Visible = False
Shape2.Visible = True
Shape3.Visible = False
If Form1.Caption > 20 Then
Shape1.Visible = True
Shape2.Visible = False
Shape3.Visible = False
Form1.Caption = "0"
End If
End If
End If
End If
End If
End Sub

COLORES Y POSICIONES


LOS OPTIION DE LOS COLORES ENLA PROPIEDAD NAME ES IGUAL AL NOMBRE DEL COLOR



CODIGO_______________________________________________________________
Private Sub amariilo_Click()
Text1.BackColor = vbYellow
End Sub

Private Sub azul_Click()
Text1.BackColor = vbBlue
End Sub

Private Sub blanco_Click()
Text1.BackColor = vbWhite
End Sub

Private Sub Command1_Click()
Text1.Text = ""
Text2.Text = ""
End Sub

Private Sub negro_Click()
Text1.BackColor = vbBlack
End Sub

Private Sub Option1_Click()
Text1.Top = 150
End Sub

Private Sub Option2_Click()
Text1.Top = 1315
End Sub

Private Sub Option3_Click()
Text1.Top = 2500
End Sub

Private Sub Option5_Click()
Text1.Text = BackColor
End Sub

Private Sub Option4_Click(Index As Integer)
Text1.ForeColor = Option4(Index).ForeColor
End Sub

Private Sub rojo_Click()
Text1.BackColor = vbRed
End Sub

Private Sub Text2_Change()
Text1.Text = Text2.Text
End Sub

Private Sub verde_Click()
Text1.BackColor = vbGreen
End Sub

PEDIDO DE COMIDAS



CODIGO_______________________________________________________________ Private Sub Combo1_Click()
'este mostrara las frutas
If Combo1.Text = "manzana" Then
Text1.Text = "10"
Text6.Text = "500"
Else
If Combo1.Text = "pera" Then
Text1.Text = "15"
Text6.Text = "600"
End If
End If
If Combo1.Text = "mango" Then
Text1.Text = "12"
Text6.Text = "400"
Else
If Combo1.Text = "papaya" Then
Text1.Text = "13"
Text6.Text = "1500"
Else
If Combo1.Text = "lulo" Then
Text1.Text = "11"
Text6.Text = "700"
End If
End If
End If
End Sub
Private Sub Combo2_Click()
'este mostrara las bebidas
If Combo2.Text = "gaseosa" Then
Text2.Text = "15"
Text7.Text = "800"
Else
If Combo2.Text = "batido" Then
Text2.Text = "25"
Text7.Text = "1000"
End If
End If
If Combo2.Text = "jugo" Then
Text2.Text = "16"
Text7.Text = "800"
Else
If Combo2.Text = "cerveza" Then
Text2.Text = "5"
Text7.Text = "1100"
Else
If Combo2.Text = "vino" Then
Text2.Text = "9"
Text7.Text = "10000"
End If
End If
End If
End Sub
Private Sub Combo3_Click()
'este es de el postre
If Combo3.Text = "gelatina" Then
Text3.Text = "11"
Text8.Text = "600"
Else
If Combo3.Text = "tres leches" Then
Text3.Text = "50"
Text8.Text = "2000"
End If
End If
If Combo3.Text = "de piña" Then
Text3.Text = "45"
Text8.Text = "1500"
Else
If Combo3.Text = "torta fria" Then
Text3.Text = "70"
Text8.Text = "800"
Else
If Combo3.Text = "kiwi" Then
Text3.Text = "65"
Text8.Text = "700"
End If
End If
End If
End Sub
Private Sub Combo4_Click()
'este mostrara los helados
If Combo4.Text = "fresa" Then
Text4.Text = "22"
Text9.Text = "600"
Else
If Combo4.Text = "chocolate" Then
Text4.Text = "42"
Text9.Text = "500"
End If
End If
If Combo4.Text = "bocato" Then
Text4.Text = "43"
Text9.Text = "2000"
Else
If Combo4.Text = "cono" Then
Text4.Text = "26"
Text9.Text = "800"
Else
If Combo3.Text = "paleta" Then
Text3.Text = "16"
Text9.Text = "700"
End If
End If
End If
End Sub

Private Sub Command1_Click()
'boton salir
End
End Sub

Private Sub Command2_Click()
'boton borrar
Combo1.Text = ""
Combo2.Text = ""
Combo3.Text = ""
Combo4.Text = ""
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
Text7.Text = ""
Text8.Text = ""
Text9.Text = ""
Text10.Text = ""
Text11.Text = ""
Text12.Text = ""
End Sub

Private Sub Form_Load()
'con este codigo adisionamos los nombres de cada objeto a la herramienta combobox
Combo1.AddItem "manzana"
Combo1.AddItem "pera"
Combo1.AddItem "mango"
Combo1.AddItem "papaya"
Combo1.AddItem "lulo"
Combo2.AddItem "gaseosa"
Combo2.AddItem "batido"
Combo2.AddItem "jugo"
Combo2.AddItem "cerveza"
Combo2.AddItem "vino"
Combo3.AddItem "gelatina"
Combo3.AddItem "tres leches"
Combo3.AddItem "de piña"
Combo3.AddItem "torta fria"
Combo3.AddItem "kiwi"
Combo4.AddItem "fresa"
Combo4.AddItem "chocolate"
Combo4.AddItem "bocato"
Combo4.AddItem "cono"
Combo4.AddItem "paleta"
End Sub
'los soguientes son para mostrar los resultados del pedido
Private Sub Label6_Click()
Text5.Text = Val(Text1.Text) + Val(Text2.Text) + Val(Text3.Text) + Val(Text4.Text)
End Sub

Private Sub Label7_Click()
Text10.Text = Val(Text6.Text) + Val(Text7.Text) + Val(Text8.Text) + Val(Text9.Text)
End Sub

Private Sub Label8_Click()
Text11.Text = (Val(Text10.Text) * 16) / 100
End Sub

Private Sub Label9_Click()
Text12.Text = Val(Text11.Text) + Val(Text10.Text)
End Sub

CONVERTIDOR DE MONEDA










CODIGO_______________________________________________________________
Private Sub Command1_Click()
Text4.Text = Text1.Text * 3000
Text5.Text = Text2.Text * 1500
Text6.Text = Text3.Text * 2500
End Sub
Private Sub Command2_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
Text5.Text = ""
Text6.Text = ""
End Sub
Private Sub Command3_Click()
End
End Sub



CONVERTIDOR DE TEMPERATURA DE GRADOS CENTIGRADOS A FAHRENHEIT





CODIGO_______________________________________________________________
Private Sub Command1_Click()
Boton salir
End
End Sub
Private Sub HScroll1_Change()
Barra de desplazamiento
HScroll1.Min = 1
HScroll1.Max = 500
HScroll1.LargeChange = 10
HScroll1.SmallChange = 1
Text1.Text = HScroll1.Value
Text2.Text = 32 + 1.8 * HScroll1.Value
End Sub
















LOS BOTONES donde se ponen los números es una matriz de controles, también donde están los operadores son matriz de controles, “esto es para ahorrar líneas de código”
CODIGO_______________________________________________________________


'declaramos un variable de tipo carácter, donde se almacenara los operadores como +, -, *, / etc.
Dim operador As String
'declaramos tres variables, donde res almacenara el resultado de la operación y var, var1, los datos ingresados por el usuario
Dim VAR, var1, res As Double
Private Sub Command1_Click(Index As Integer)
'valor del caption de cada boton dentro de la matriz se mostrara en la caja de testo de nombre pantalla
pantalla.Text = pantalla.Text & Command1(Index).Caption
End Sub
Private Sub Command11_Click()
'boton borrar un numero
pantalla.Text = StrReverse(Mid(StrReverse(pantalla.Text), 2))
End Sub
Private Sub Command12_Click()
'boton raiz cuadrada
pantalla.Text = Sqr(Val(pantalla.Text))
End Sub
Private Sub Command2_Click()
'borrar la pantalla
pantalla.Text = ""
End Sub
Private Sub Command4_Click()
'boton igual
'compara si la pantalla esta en blanco
If pantalla.Text = "" Then
Else
' almacena el segundo numero y limpia la pantalla
var1 = pantalla.Text
pantalla.Text = ""
Select Case operador
'selecciona el valor que tiene lavariable operador
Case "-": res = Val(VAR) - Val(var1)
Case "+": res = Val(VAR) + Val(var1)
Case "*": res = Val(VAR) * Val(var1)
Case "/": Call divi0
Case "\": Call ente0
Case "MOD": Call modu
Case "%": Call porce
End Select
pantalla.Text = res
End If
End Sub
Private Sub Command5_Click(Index As Integer)
'botones de los operadores almacenados en una matriz de controles
'comprueba si la pantalla esta en blanco
If pantalla.Text = "" Then
Else
'almacena el numero en pantalla y luego la limpia
VAR = pantalla.Text
pantalla.Text = ""
'almacena el caption de cualqiuer boton de operacion en la variable operador
operador = Command5(Index).Caption
End If
End Sub
Private Sub Command6_Click()
'boton borrar
End
End Sub
Private Sub Command9_Click()
'boton cero
If pantalla.Text = "0" Then
pantalla.Text = pantalla.Text & ".0"
Else
pantalla.Text = pantalla.Text & Command9.Caption
End If
End Sub
Private Sub Form_Load()
'carga el valor a los botones de los números
For i = 1 To 9
Command1(i).Caption = i
Next
Command9.Caption = 0
End Sub
Function divi0()
' funcion que comprueba que si el valor a dividicion por cero le avise al susuario de lo contrario realiza la divicion
If var1 = 0 Then
MsgBox "NO ES POSIBLE LA DIVISION POR CERO (0) "
Else
res = VAR / var1
End If
End Function
Function ente0()
' funcion que comprueba que si el valor a dividicion entera es por cero le avise al susuario de lo contrario realiza la divicion entera
If var1 = 0 Then
MsgBox "NO ES POSIBLE LA DIVISION ENTERA POR CERO (0) "
Else
res = VAR \ var1
End If
End Function
Function modu()
' funcion que comprueba que si el valor a dividir es por cero le avise al susuario de lo contrario realiza la modulo
If var1 = 0 Then
MsgBox "NO ES POSIBLE HALLAR EL MODULO POR CERO (0)"
Else
res = VAR Mod var1
End If
End Function
Function porce()
' funcion que comprueba que si el valor a dividir es por cero le avise al susuario de lo contrario realiza la porcentaje
If var1 = 0 Then
MsgBox "NO ES POSIBLE HALLAR EL 0% DE " & VAR
Else
res = (VAR * var1) / 100
End If
End Function

ORDENADOR DE TRES NUMEROS

Este programa muestra el orden ascendente de tres números ingresados por el usuario

CODIGO_______________________________________________________________
Private Sub Command1_Click()
'boton calcular, en el cual realiza toda comparación posible
If Val(Text1.Text) > Val(Text2.Text) Then
If Val(Text1.Text) > Val(Text3.Text) Then
Label2.Caption = Text1.Text
Label3.Caption = Text3.Text
Label4.Caption = Text2.Text
Else
Label2.Caption = Text3.Text
Label3.Caption = Text1.Text
Label4.Caption = Text2.Text
End If
Else
If Val(Text2.Text) > Val(Text3.Text) Then
Label2.Caption = Text2.Text
Label3.Caption = Text3.Text
Label4.Caption = Text1.Text
Else
Label2.Caption = Text3.Text
Label3.Caption = Text2.Text
Label4.Caption = Text1.Text
End If
End If
End Sub
Private Sub Command2_Click()
'boton borrar
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Label2.Caption = ""
Label3.Caption = ""
Label4.Caption = ""
Text1.SetFocus
End Sub
Private Sub Command3_Click()
boton salir
End
End Sub

CALCULADORA BASICA
Este es un programa donde el usuario podrá ingresar dos números en el cual puede realizar operaciones básicas como suma, resta, división, etc. Es un modelo previo de un calculadora actual.


CODIGO_______________________________________________________________
'declaramos dos variables que serán donde se guardaran los datos ingresados por el usuario
Dim VAR1, VAR2 As Double
'declaramos un serie de variables que mostraran el resultado de cada operación correspondiente
Dim MULTI, SUMA, DIVI, RESTA, PRO, ENT, MODULO, POR As Double
Private Sub Command1_Click()
'boton sumar
VAR1 = Text1.Text
VAR2 = Text2.Text
SUMA = VAR1 + VAR2
Text3.Text = SUMA
End Sub
Private Sub Command10_Click()
'boton modulo
VAR1 = Text1.Text
VAR2 = Text2.Text
MODULO = VAR1 Mod VAR2
Text3.Text = MODULO
End Sub
Private Sub Command2_Click()
'boton multiplicar
VAR1 = Text1.Text
VAR2 = Text2.Text
MULTI = VAR1 * VAR2
Text3.Text = MULTI
End Sub
Private Sub Command3_Click()
'boton resta
VAR1 = Text1.Text
VAR2 = Text2.Text
RESTA = VAR1 - VAR2
Text3.Text = RESTA
End Sub
Private Sub Command4_Click()
'boton division
VAR1 = Text1.Text
VAR2 = Text2.Text
DIVI = VAR1 / VAR2
Text3.Text = DIVI
End Sub
Private Sub Command5_Click()
'boton multiplicación
VAR1 = Text1.Text
VAR2 = Text2.Text
PRO = (VAR1 + VAR2) / 2
Text3.Text = PRO
End Sub
Private Sub Command6_Click()
'boton salir
End
End Sub
Private Sub Command7_Click()
'boton borra
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub
Private Sub Command8_Click()
'boton porcentaje
VAR1 = Text1.Text
VAR2 = Text2.Text
POR = (VAR1 * VAR2) / 100
Text3.Text = POR
End Sub
Private Sub Command9_Click()
'botón división entera
VAR1 = Text1.Text
VAR2 = Text2.Text
ENT = VAR1 \ VAR2
Text3.Text = ENT
End Sub
AREA DE UN CÍRCULO

Este es un programa donde el usuario ingresando el valor del radio del circulo obtendrá el área del dicho circulo utilizaremos tres botones “commandbuton” para utilizarlos como calcular, salir y nuevo








CODIGO_______________________________________________________________
'DECLARAMOS DOSVARIABLES
Dim AREA, PI As Double
Private Sub Command1_Click()
'ESTE ES EL BOTON CALCULAR
If Text1.Text = "" Then
MsgBox "DIGITE EL VALOR DEL RADIO EN LA CAJA DE TEXTO"
Else
PI = 3.1416
AREA = (Val(Text1.Text) * Val(Text1.Text)) * PI
MsgBox "EL AREA DEL CIRCULO ES " & AREA
End If
End Sub
Private Sub Command2_Click()
'BOTON SALIR
End
End Sub
Private Sub Command3_Click()
'BOTON NUEVO
Text1.Text = ""
Text1.SetFocus
End Sub