Ir ao conteúdo
  • Cadastre-se

Calculadora em VB 2008


Pablo Weber

Posts recomendados

Ola pessoal, estou criando uma calculadora simples, para ir me acostumando com os comandos do VB, crieu um Form com um TextBox para inserção dos números,e criei alguns botões (0 a 9, +, -, =, /, *, CE e Fim), n'ao consigo fazer o codigo dos botões de +, -, =, /, * ), pois todos os exemplos que vi na Net são de 2 ou 3 TextBox, onde soman-se 2 TextBox para revelar o valor em um terceiro. Qual o procedimento a ser feito pessoal. Ja tentei diversas formas, mas não consigo. Obrigado.

Link para o comentário
Compartilhar em outros sites

Olá Pablo weber,

Eu não sei se você quer o código completo ou se você mesmo quer desenvolver,

Eu vou te passar o código completo e você vê para ter uma ideia.

ublic Class Form1
Dim A As Integer
Dim B As Integer
Dim C As Integer
Dim D As Integer
Dim L As Integer
Dim F As Integer
Dim G As Integer
Dim H As Integer
Dim I As Integer
Dim J As Integer
Dim K As Integer
Dim Fator As Integer
Dim Val As Integer
Dim Memoria As Integer

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

End Sub

Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If (TextBox1.Text <> 0) Then
A = (TextBox1.Text)
B = (1)
TextBox1.Text = (A &
End If
If (TextBox1.Text = 0) Then
B = (1)
TextBox1.Text = (
End If
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If (TextBox1.Text <> 0) Then
A = (TextBox1.Text)
C = (2)
TextBox1.Text = (A & C)
End If
If (TextBox1.Text = 0) Then
C = (2)
TextBox1.Text = (C)
End If
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
If (TextBox1.Text <> 0) Then
A = (TextBox1.Text)
D = (3)
TextBox1.Text = (A & D)
End If
If (TextBox1.Text = 0) Then
D = (3)
TextBox1.Text = (D)
End If
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
If (TextBox1.Text <> 0) Then
A = (TextBox1.Text)
L = (4)
TextBox1.Text = (A & L)
End If
If (TextBox1.Text = 0) Then
L = (4)
TextBox1.Text = (L)
End If
End Sub

Private Sub Button6_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button6.Click
If (TextBox1.Text <> 0) Then
A = (TextBox1.Text)
F = (5)
TextBox1.Text = (A & F)
End If
If (TextBox1.Text = 0) Then
F = (5)
TextBox1.Text = (F)
End If
End Sub

Private Sub Button7_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button7.Click
If (TextBox1.Text <> 0) Then
A = (TextBox1.Text)
G = (6)
TextBox1.Text = (A & G)
End If
If (TextBox1.Text = 0) Then
G = (6)
TextBox1.Text = (G)
End If
End Sub

Private Sub Button9_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
If (TextBox1.Text <> 0) Then
A = (TextBox1.Text)
H = (7)
TextBox1.Text = (A & H)
End If
If (TextBox1.Text = 0) Then
H = (7)
TextBox1.Text = (H)
End If
End Sub

Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click
If (TextBox1.Text <> 0) Then
A = (TextBox1.Text)
I = (8)
TextBox1.Text = (A & I)
End If
If (TextBox1.Text = 0) Then
I = (8)
TextBox1.Text = (I)
End If
End Sub

Private Sub Button11_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button11.Click
If (TextBox1.Text <> 0) Then
A = (TextBox1.Text)
J = (9)
TextBox1.Text = (A & J)
End If
If (TextBox1.Text = 0) Then
J = (9)
TextBox1.Text = (J)
End If
End Sub

Private Sub Button13_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button13.Click
If (TextBox1.Text <> 0) Then
A = (TextBox1.Text)
K = (0)
TextBox1.Text = (A & K)
End If
If (TextBox1.Text = 0) Then
K = (0)
TextBox1.Text = (K)
End If
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Val = (TextBox1.Text)
TextBox1.Text = (0)
Fator = (1)
End Sub

Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
Val = (TextBox1.Text)
TextBox1.Text = (0)
Fator = (2)
End Sub

Private Sub Button12_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button12.Click
Val = (TextBox1.Text)
TextBox1.Text = (0)
Fator = (3)
End Sub

Private Sub Button14_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button14.Click
Val = (TextBox1.Text)
TextBox1.Text = (0)
Fator = (4)
End Sub

Private Sub Button15_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button15.Click
If (Fator = 1) Then
A = ((Val) + (TextBox1.Text))
TextBox1.Text = (A)
End If
If (Fator = 2) Then
A = ((Val) - (TextBox1.Text))
TextBox1.Text = (A)
End If
If (Fator = 3) Then
A = ((Val) * (TextBox1.Text))
TextBox1.Text = (A)
End If
If (Fator = 4) Then
A = ((Val) / (TextBox1.Text))
TextBox1.Text = (A)
End If
End Sub

Private Sub Button16_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button16.Click
TextBox1.Text = (0)
A = (0)
Fator = (0)
End Sub

Private Sub Button18_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button18.Click
TextBox1.Text = (0)
End Sub

Private Sub Button19_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button19.Click
Memoria = (TextBox1.Text)
End Sub

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

Não fui eu que criei, acredito que os créditos estejam na própria calculadora.

Link para o comentário
Compartilhar em outros sites

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

Ebook grátis: Aprenda a ler resistores e capacitores!

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!