Jump to content

Calculadora!


DuroPt
 Share

Recommended Posts

Olá sou novo novo novo =P

Este é o meu problema, estava  tentar fazer uma calculadora, e comecei por por este código:

Private Sub Command1_Click(Index As Integer)

Select Case Index

Select Case 0

Label1.Caption = Label1.Caption & "0"

Select Case 1

Label1.Caption = Label1.Caption & "1"

Select Case 2

Label1.Caption = Label1.Caption & "2"

Select Case 3

Label1.Caption = Label1.Caption & "3"

Select Case 4

Label1.Caption = Label1.Caption & "4"

Select Case 5

Label1.Caption = Label1.Caption & "5"

Select Case 6

Label1.Caption = Label1.Caption & "6"

Select Case 7

Label1.Caption = Label1.Caption & "7"

Select Case 8

Label1.Caption = Label1.Caption & "8"

Select Case 9

Label1.Caption = Label1.Caption & "9"

End Select

End Sub

Quando meti play, só para ver se estava a funcionar, tudo bem, quando cliquei numa tecla, qualquer que seja, deu o seguinte erro: "  Compile error: Statements and labels invalid between Select case and first case"

Não entendo! Abraços!

Link to comment
Share on other sites

exacto, enganeime eu passo o codigo

Private Sub Command1_Click(Index As Integer)
Select Case Index
  Case 0
Label1.Caption = Label1.Caption & "0"
Case 1
Label1.Caption = Label1.Caption & "1"
Case 2
Label1.Caption = Label1.Caption & "2"
Case 3
Label1.Caption = Label1.Caption & "3"
Case 4
Label1.Caption = Label1.Caption & "4"
Case 5
Label1.Caption = Label1.Caption & "5"
Case 6
Label1.Caption = Label1.Caption & "6"
Case 7
Label1.Caption = Label1.Caption & "7"
Case 8
Label1.Caption = Label1.Caption & "8"
Case 9
Label1.Caption = Label1.Caption & "9"
End Select
End Sub

ve la agora

Got it?

Link to comment
Share on other sites

Private Sub Command1_Click(Index As Integer)

Dim K As Integer

Select Case Index

Case 0

Label1.Caption = Label1.Caption & "0"

Case 1

Label1.Caption = Label1.Caption & "1"

Case 2

Label1.Caption = Label1.Caption & "2"

Case 3

Label1.Caption = Label1.Caption & "3"

Case 4

Label1.Caption = Label1.Caption & "4"

Case 5

Label1.Caption = Label1.Caption & "5"

Case 6

Label1.Caption = Label1.Caption & "6"

Case 7

Label1.Caption = Label1.Caption & "7"

Case 8

Label1.Caption = Label1.Caption & "8"

Case 9

Label1.Caption = Label1.Caption & "9"

Case 10 'Este é o comando com o sinal +(mais)

K = Label1.Caption 'Para dar um valor a K, para que mais tarde seja somado

Label1.Caption = "" 'para limpar a label

End Select

End Sub

Não consigo sair daqui, alguem já tem uma calculadora feita, para eu ver o código e tentar perceber

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.