1.
Código:
Private Sub Command1_Click()
Dim peso As Single, i As Integer, soma As Integer
i = 0
soma = 0
Do
Do
peso = Val(InputBox("Introduza o peso", "Entrada de dados"))
If peso < 0 Then
MsgBox "O peso que introduziu é inválido", vbCritical, "Aviso"
End If
Loop While peso < 0
If peso <> 0 Then
soma = soma + peso
i = i + 1
End If
If soma > 450 Then
MsgBox "Peso Excessivo", vbCritical, "Aviso"
End
End If
If i > 6 Then
MsgBox "Peso Excessivo", vbCritical, "Aviso"
End
End If
Loop While peso <> 0
MsgBox "O peso total é " & peso, vbInformation, "Saída"
End Sub
2.
Código:
Private Sub Command1_Click()
Dim i As Integer, cont As Integer, j As Integer
j = 1
cont = 0
i = 1
Do
Do
If i Mod j = 0 Then
cont = cont + 1
End If
j = j + 1
Loop While j < 10
If cont = 2 Then
Picture1.Print i
End If
j = 1
cont = 0
i = i + 1
Loop While i < 10
End Sub
3.
Código:
Private Sub Command1_Click()
Dim num As Integer, i As Integer
divisores = 0
i = 1
Do
num = Val(InputBox("Introduza um número", "Entrada de dados"))
If num < 0 Then
MsgBox "O número que introduziu é inválido", vbCritical, "Saída"
End If
Loop Until num > 0
Do
If num Mod i = 0 Then
Picture1.Print i
End If
i = i + 1
Loop Until i > num
End Sub
4.
Código:
Private Sub Command1_Click()
Dim preco As Single, soma As Single, forma_pagamento As Integer, opcao As Integer, desconto As Single, total As Single
Const D_C = 0.1, CC = 0.05, V_3 = 0.1
soma = 0
MsgBox "Introduza o número 0 para encerrar a compra", vbInformation, "Aviso"
Do
Do
preco = Val(InputBox("Introduza o preço do produto", "Entrada de preços"))
If preco < 0 Then
MsgBox "Preço inválido", vbCritical, "Aviso"
ElseIf preco = 0 Then
opcao = MsgBox("Tem a certeza que quer encerrar a compra?", vbQuestion + vbYesNo, "Confirmação")
ElseIf preco > 0 Then
soma = soma + preco
End If
Loop While preco > 0
Loop Until opcao = vbYes
Do
forma_pagamento = Val(InputBox("Introduza o código da condição de pagamento", "Código"))
If forma_pagamento < 1 Or forma_pagamento > 4 Then
MsgBox "O código é inválido", vbCritical, "Aviso"
End If
Loop While forma_pagamento < 1 Or forma_pagamento > 4
Select Case forma_pagamento
Case 1
desconto = soma * D_C
total = soma - desconto
Case 2
desconto = soma * CC
total = soma - desconto
Case 3
total = soma
Case 4
desconto = soma * V_3
total = soma + desconto
End Select
MsgBox "O total da compra é " & total
End Sub
Sem comentários:
Enviar um comentário