Professional Documents
Culture Documents
ProgramacionenvisualBasic2008
2
Ms Siguienteblog
ProgramacionenvisualBasic2008
BlogelaboradoconlaintencindefacilitardiferentesejerciciossobreVisualBasic2008y2010explicadospasoapaso
DOMINGO,21DEOCTUBREDE2012
ARCHIVODELBLOG
2012(5)
CalcularEdad
octubre(5)
BuenoenestaQuintaentregalestraigounapequeaaplicacin,quenossirveparacalcular,la
edad, los das vividos y las horas vividas, para este proyecto agreguemos a nuestro form1 los
siguientesobjetos:
CalcularEdad
CambiodeImagen
Calculareliva
CalculadoraSencilla
4label
4textBox
2Button=CalcularySalir
Imagen1
Elfamoso"HolaMundo"
DATOS
PERSONALES
AldoFoschini
Seguir
Vertodomiperfil
Lafechadenacimientotieneelformatosiguiente:12/04/1990
Codificacin:
Enelbotncalculardamosdoblecliceintroducimoselcdigosiguiente:
PrivateSubBtnCalcular_Click(ByValsenderAsSystem.Object,ByValeAs
System.EventArgs)HandlesBtnCalcular.Click
DimfnacAsDate=Convert.ToDateTime(TextBox1.Text())
DimEdadAsInt32
DimDiferenciaAsTimeSpan
Diferencia=Today.Subtract(fnac)
Edad=Fix(Diferencia.TotalDays/365.25)
TextBox2.Text()=Diferencia.TotalDays.ToString
TextBox3.Text()=Diferencia.TotalHours.ToString
TextBox4.Text()=Edad.ToString
EneltextBox1damosdobleclicyeintroducimoselcodigosiguiente:
PrivateSubTextBox1_TextChanged(ByValsenderAsSystem.Object,ByVale
AsSystem.EventArgs)HandlesTextBox1.TextChanged
IfIsDate(TextBox1.Text)Then
BtnCalcular.Enabled=True
Else
BtnCalcular.Enabled=False
EndIf
EndSub
EndClass
http://aprendecodigofacil.blogspot.com/
1/7
19/10/2016
ProgramacionenvisualBasic2008
EnelBotonSalirdamosdoblecliceintroducimoselcodigosiguiente.
DimrAsInt32
r=MessageBox.Show("Estasegurodesalir","salir",_
MessageBoxButtons.YesNo,MessageBoxIcon.Question,_
MessageBoxDefaultButton.Button1)
Ifr=Windows.Forms.DialogResult.YesThen
Application.Exit()
Else
TextBox1.Clear()
TextBox2.Clear()
TextBox3.Clear()
TextBox4.Clear()
TextBox1.Focus()
EndIf
EndSub
Bueno ya pueden saber cuantos aos tienen, cuantos dias y horas han vivido y espero en la
proximaentregacalcularlosdiasquelesfaltaporvivir?..Losesperoenlaproximaentregaque
vaaestarunpocomasdificil,muchasgraciasydejensuscomentariosporfavor.
PublicadoporAldoFoschinien20:16
3comentarios:
CambiodeImagen
Buenoenestacuartaentregalestraigounapequeaaplicacin,queinteracta2imgenesen
empodeejecucin,paraesteproyectoagreguemosanuestroform1lossiguientesobjetos:
2picturebox
1 mer
Enelprimerpictureboxcolocamosunaimagencualquieraylecambiamossupropiedad
sizeModeaStretchImage,enelsegundopictureboxhacemoslomismo,perocambiandode
imagen
Al merlecambiamoslapropiedadEnabledaTrueeintervala2000
Imagen1
Codicacin
En merhacemosdobleCliceintroducimoselcdigosiguientecomosemuestraa
con nuacin:
http://aprendecodigofacil.blogspot.com/
2/7
19/10/2016
ProgramacionenvisualBasic2008
PrivateSubTimer1_Tick(ByValsenderAsSystem.Object,ByValeAsSystem.EventArgs)Handles
Timer1.Tick
PictureBox2.Visible=NotPictureBox2.Visible
EndSub
EndClass
CorremosnuestroproyectoconF5yvernlosresultados,buenoesoestodoesperolesguste
estaaplicacinnosvemosenlaprximaentrega,dejensuscomentariosporfavor
PublicadoporAldoFoschinien19:40
Nohaycomentarios:
LUNES,8DEOCTUBREDE2012
Calculareliva
Buenoestaesmiterceraentrada,estavezlestraigounprogramaquelessirvepara
calcularelIVAdeunproducto,lospasosparahaceresteprogramasonlossiguientes:
1.AbrimosnuestrovisualBasic2008
2.PonemoscomonombreCalcularIVA
3.Ennuestroform1ponemosloscontrolessiguientes:
<6Label
<2TextBox
<3Button
AlosControleslecambiamoslosnombresenlapropiedadNameytextas:
Label
Name
Text
Label1
NombredelCliente
Label2
MontodelaFactura
Label3
Importe
Label5
IGV(16%)
Label6=LblImporte
EnBlanco
Label7=lblIgv
EnBlanco
Figura#1
http://aprendecodigofacil.blogspot.com/
3/7
19/10/2016
ProgramacionenvisualBasic2008
TextBox
Name
TxtCliente
TxtMonto
Text
EnBlanco
EnBlanco
Button
Name
Text
Button1=btncalcular
calcular
Button2=btnNuevo
Nuevo
Button3=btncerrar
Cerrar
4.AhoravienelacodificacindelosButton
5.EnelButton1oCalculardamosdoblecliceingresamoselsiguientecdigo:
Dimmonto,importe,igvAsDouble
monto=Double.Parse(TxtMonto.Text)
igv=monto*0.16
importe=montoigv
lblImporte.Text=importe.ToString("###,##0.00")
lblIgv.Text=igv.ToString("###,##0.00")
6.EnelButton2oNuevoingresamoselcodigosiguiente:
TxtCliente.Text=""
TxtMonto.Text=""
lblImporte.Text=""
lblIgv.Text=""
TxtCliente.Focus()
7.EnelButton3oCerraringresamoselcodigosiguiente:
End
Figura2
PublicClassForm1
PrivateSubbtncalcular_Click(ByValsenderAsSystem.Object,ByVale
AsSystem.EventArgs)Handlesbtncalcular.Click
Dimmonto,importe,igvAsDouble
monto=Double.Parse(TxtMonto.Text)
igv=monto*0.16
importe=montoigv
lblImporte.Text=importe.ToString("###,##0.00")
lblIgv.Text=igv.ToString("###,##0.00")
EndSub
PrivateSubbtnNuevo_Click(ByValsenderAsSystem.Object,ByValeAs
System.EventArgs)HandlesbtnNuevo.Click
TxtCliente.Text=""
TxtMonto.Text=""
lblImporte.Text=""
lblIgv.Text=""
TxtCliente.Focus()
EndSub
PrivateSubbtncerrar_Click(ByValsenderAsSystem.Object,ByVale
AsSystem.EventArgs)Handlesbtncerrar.Click
End
EndSub
EndClass
Buenoaquterminaestaentregaesperoleshayagustado,cualquierinquietudnodudenen
informarme
http://aprendecodigofacil.blogspot.com/
4/7
19/10/2016
ProgramacionenvisualBasic2008
PublicadoporAldoFoschinien18:55
Nohaycomentarios:
CalculadoraSencilla
Buenoenestaocasinlestraigounacalculadorasencilla,esperoseadesu
agrado.Lospasosparahaceresteproyectosonlossiguientes:
1.creamosunproyectonuevoenVisualBasic
2.LeponemospornombreCalculadora
3.EnelForm1colocamoslosiguiente:
1GroupBox
4RadioButton
3Label
3textBox
3Button
Aloscontrolesselecambianlosnombresenlapropiedadtextas:
RadioButton
Name
OpSuma
OpResta
OpMultiplicar
OpDividir
Text
Suma
Resta
Multiplicar
Divisin
Label
Name
Label1
Label2
Label3
Text
PrimerNumero
SegundoNumero
TercerNumero
TextBox
Name
Text1
Text2
Text3
Text
SedejaenBlanco
SedejaenBlanco
SedejaenBlanco
Button
Name
Button1
Button2
Button3
http://aprendecodigofacil.blogspot.com/
Text
Calcular
Limpiar
Salir
5/7
19/10/2016
ProgramacionenvisualBasic2008
Figura#1
4.ComenzamosacodificarcadaButton:
Button1=Calcular
PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAs
System.EventArgs)HandlesButton1.Click
Ifopcsumar.CheckedThen
Txt3.Text=Val(Txt1.Text)+Val(Txt2.Text)
ElseIfopcrestar.CheckedThen
Txt3.Text=Val(Txt1.Text)*Val(Txt2.Text)
ElseIfopcmultiplicar.CheckedThen
Txt3.Text=Val(Txt1.Text)Val(Txt2.Text)
ElseIfopcdividir.CheckAlignThen
Txt3.Text=Val(Txt1.Text)/Val(Txt2.Text)
EndIf
EndSub
Button2=Limpiar
PrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAs
System.EventArgs)HandlesButton2.Click
Txt1.Text=""
Txt2.Text=""
Txt3.Text=""
EndSub
Button3=Salir
PrivateSubButton3_Click(ByValsenderAsSystem.Object,ByValeAs
System.EventArgs)HandlesButton3.Click
End
EndSub
EndClass
Figura#2
PublicClassForm1
PrivateSubButton1_Click(ByValsenderAsSystem.Object,ByValeAs
System.EventArgs)HandlesButton1.Click
Ifopcsumar.CheckedThen
Txt3.Text=Val(Txt1.Text)+Val(Txt2.Text)
ElseIfopcrestar.CheckedThen
Txt3.Text=Val(Txt1.Text)*Val(Txt2.Text)
ElseIfopcmultiplicar.CheckedThen
Txt3.Text=Val(Txt1.Text)Val(Txt2.Text)
ElseIfopcdividir.CheckAlignThen
Txt3.Text=Val(Txt1.Text)/Val(Txt2.Text)
EndIf
EndSub
http://aprendecodigofacil.blogspot.com/
6/7
19/10/2016
ProgramacionenvisualBasic2008
PrivateSubButton2_Click(ByValsenderAsSystem.Object,ByValeAs
System.EventArgs)HandlesButton2.Click
Txt1.Text=""
Txt2.Text=""
Txt3.Text=""
EndSub
PrivateSubButton3_Click(ByValsenderAsSystem.Object,ByValeAs
System.EventArgs)HandlesButton3.Click
End
EndSub
EndClass
5.ListoejecutamosnuestroprogramaconF5,buenoesoestodoesperotraerles
muyprontomiterceraentrada,cualquierdudaocomentarioconmuchogusto
lesrespondermuchasgracias.
PublicadoporAldoFoschinien12:40
5comentarios:
Pginaprincipal
Entradasantiguas
Suscribirsea:Entradas(Atom)
PlantillaPictureWindow.ConlatecnologadeBlogger.
http://aprendecodigofacil.blogspot.com/
7/7