Buscar : en
Por :

Hacer una calculadora en visual basic

Última respuesta el 8 sep 2009, 16:53:14 arte202312, el 27 may 2009, 03:24:03 
 Señalar este mensaje a los moderadores

Hola,

chicos necesito de su ayuda quiero hacer una calculadora en visual basic de excel 2003 pero como puedo hacer que en un textbox se inserte los numeros al apretar el commandbutton con el numero asignado de manera concatenada la calculadora la quiero hacer igual p parecida a la de windows xp o vista

Configuración: Windows Vista Internet Explorer 8.0

Mejores respuestas para « hacer una calculadora en visual basic » en :
[Mito] Visual Basic es un lenguaje orientado a objetos VerMito Visual Basic es un lenguaje orientado a objetos. Realidad FALSO Explicación: Este mito es popular, pero desafortunadamente es falso: VB6 no es un lenguaje orientado a objetos. Veamos las características de los lenguajes orientados a...
Error del sistema &H80004005 (-2147467259) VerSi al abrir Excel te aparece una ventana emergente “Microsoft Visual Basic” conteniendo el mensaje de error: Error del sistema &H80004005 (-2147467259). Error no especificado Para solucionar este problema: Abre Excel Ignora el mensaje de...
Descargar Visual Basic Runtime Files VerVisual Basic Runtime Files 6.0 contiene un conjunto de librerias (DLL) necesarias para ejecutar programas escritos en lenguaje Visual Basic 6.0 Contiene las DLL siguientes: - asycfilt.dll - COMCAT.DLL - msvbvm60.dll - OLEAUT32.DLL -...

1

DioSystem, el 27 jun 2009, 17:08:14
  • +19

Primero inserta 6 Command Button, 3 TextBox y 3 Label

Los command Button deberan llevar el siguiente "Caption":

Limpiar, sumar, restar, multiplicar, dividir y salir.

Las 3 Labels deberan in encima de cada TextBoxt. Dejalas sin Nombre.

Aqui esta el codigo de una calculadora sencilla en Visual Basic 6.0

Private Sub Form_Load()
Label1.Caption = "1 Numero"
Label2.Caption = "2 Numero"
Label3.Caption = "Resultado"
End Sub

Private Sub Cerrar_Click()
Unload Me
End Sub

Private Sub Command1_Click()
Text3.Text = Text1.Text * Text2.Text
End Sub

Private Sub Dividir_Click()
Text3.Text = Text1.Text / Text2.Text
End Sub

Private Sub Limpiar_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub

Private Sub RESTAR_Click()
Text3.Text = Text1.Text - Text2.Text
End Sub

Private Sub Sumar_Click()
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
End Sub

Responder a DioSystem

2

angelita, el 29 ago 2009, 21:11:43
  • +7

Primero inserta 6 Command Button, 3 TextBox y 3 Label

Los command Button deberan llevar el siguiente "Caption":

Limpiar, sumar, restar, multiplicar, dividir y salir.

Las 3 Labels deberan in encima de cada TextBoxt. Dejalas sin Nombre.

Aqui esta el codigo de una calculadora sencilla en Visual Basic 6.0

Private Sub Form_Load()
Label1.Caption = "1 Numero"
Label2.Caption = "2 Numero"
Label3.Caption = "Resultado"
End Sub

Private Sub Cerrar_Click()
Unload Me
End Sub

Private Sub Command1_Click()
Text3.Text = Text1.Text * Text2.Text
End Sub

Private Sub Dividir_Click()
Text3.Text = Text1.Text / Text2.Text
End Sub

Private Sub Limpiar_Click()
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
End Sub

Private Sub RESTAR_Click()
Text3.Text = Text1.Text - Text2.Text
End Sub

Private Sub Sumar_Click()
Text3.Text = Val(Text1.Text) + Val(Text2.Text)
End Sub

Responder a angelita

3

RobS, el 4 sep 2009, 17:04:39
  • +2

Gracias por la ayda sabes quisiera saber que mas sabes y si me podrias enseñar espero tu respuesta cuidate muxo chau

Responder a RobS

4

 *******, el 8 sep 2009, 16:53:14
  • +7

Private Sub cmd0_Click()
Clear
Text1.Text = Text1.Text & "0"
End Sub

Private Sub cmd1_Click()
Clear
Text1.Text = Text1.Text & "1"
End Sub

Private Sub cmd2_Click()
Clear
Text1.Text = Text1.Text & "2"
End Sub

Private Sub cmd3_Click()
Clear
Text1.Text = Text1.Text & "3"
End Sub

Private Sub cmd4_Click()
Clear
Text1.Text = Text1.Text & "4"
End Sub

Private Sub cmd5_Click()
Clear
Text1.Text = Text1.Text & "5"
End Sub

Private Sub cmd6_Click()
Clear
Text1.Text = Text1.Text & "6"
End Sub

Private Sub cmd7_Click()
Clear
Text1.Text = Text1.Text & "7"
End Sub

Private Sub cmd8_Click()
Clear
Text1.Text = Text1.Text & "8"
End Sub

Private Sub cmd9_Click()
Clear
Text1.Text = Text1.Text & "9"
End Sub

Private Sub cmdback_Click()
Text1.Text = StrReverse(Mid(StrReverse(Text1.Text), 2))
End Sub

Private Sub cmdc_Click()
Form_Load
End Sub

Private Sub cmdce_Click()
Text1.Text = ""
End Sub

Private Sub cmdinverse_Click()
If Text1 <> "0" And Text1 <> "" Then
Text1.Text = 1 / (Val(Text1.Text))
Else
MsgBox "División por cero"
End If
End Sub

Private Sub cmdmc_Click()
M = 0
lblmem.Caption = ""
End Sub

Private Sub cmdmp_Click()
M = M + Val(Text1.Text)
lblmem.Caption = "M"
End Sub

Private Sub cmdmr_Click()

Text1.Text = M
End Sub

Private Sub cmdms_Click()
M = Text1.Text
lblmem.Caption = "M"
End Sub

Private Sub cmdpoint_Click()
Text1.Text = Text1.Text & "."
End Sub

Private Sub cmdsign_Click()
If blnsign = False Then
Text1.Text = "-" & Text1.Text
blnsign = True
Else
Text1.Text = Val(Mid(Text1.Text, 2))
blnsign = False
End If

End Sub


Private Sub cmdadd_Click()
Cal
Flag = "add"
End Sub


Private Sub cmdminus_Click()
Cal
Flag = "minus"
End Sub

Private Sub cmdmultiply_Click()
Cal
Flag = "multiply"
End Sub

Private Sub cmddivide_Click()
Cal
Flag = "divide"
End Sub


Private Sub cmdequal_Click()

Select Case Flag
Case "add"
C = A + Val(Text1.Text)
Text1.Text = C
Case "divide"
C = A / Val(Text1.Text)
Text1.Text = C
Case "multiply"
C = A * Val(Text1.Text)
Text1.Text = C
Case "minus"
C = A - Val(Text1.Text)
Text1.Text = C
End Select

Flag = ""
A = 0
B = 0
C = 0

End Sub


Private Sub cmdsqrt_Click()
Text1.Text = Sqr(Text1.Text)
End Sub


Private Sub Form_Load()
'mnuItemPaste.Enabled = False
Text1.Text = ""
A = 0
B = 0
C = 0
M = 0
Flag = ""
blnsign = False
Cl = False
End Sub

Private Sub mnuItemCopy_Click()
mnuItemPaste.Enabled = True
End Sub

luego en un modulo****************************************


Public A As Double
Public B As Double
Public C As Double
Public M As Double
Public Flag As String
Public Cl As Boolean
Public blnsign As Boolean



Sub Clear()
If Cl = True Then
Form1.Text1.Text = ""
Cl = False
End If
End Sub

Sub Cal()
Select Case Flag
Case "add"
A = A + Val(Form1.Text1.Text)
Case "minus"
A = A - Val(Form1.Text1.Text)
Case "multiply"
A = A * Val(Form1.Text1.Text)
Case "divide"
If Val(Form1.Text1.Text) <> 0 Then A = A / Val(Form1.Text1.Text)
Case Else
A = Val(Form1.Text1.Text)
End Select

Form1.Text1.Text = A
Cl = True

End Sub

Responder a *******