Ir para conteúdo
Fórum Script Brasil
  • 0

Calculo com alguma textbox vazia


regfsd

Pergunta

OLÁ PESSOAL, ESTOU PRECISANDO DE AJUDA!

CRIRI UM PROJETO EM VB 2005 O QUAL POSSUI VARIAS TEXTBOX, CRIRI O CÓDIGO E QUANDO TODAS TEXTBOX ESTÃO PREENCHIDAS O CÓDIGO FUNCIONA CORRETAMENTE, PORÉM GOSTARIA QUE EM ALGUM MOMENTO ALGUMAS TEXTBOX FICASSEM VAZIAS.

EX.: ESTE FORMULARIO QUE ESTOU A CRIAR SERIA COMO UM PEDIDO:

ITEM 1 = DESCRIÇÃO , QUANTIDADE VEZES ÁREA VEZES NUMERO DE CORES VEZES VALOR POR CM = R$00,00

ITEM 2 = " " " " " " " " " = "

ITEM 3 = " " " " " " " " " = "

ITEM 4= " " " " " " " " " = "

ITEM 4= " " " " " " " " " = "

VALOR A PAGAR: R$ 00,00

------------------------------------------------------------------------------------------------------------------------------------

VEJA ABAIXO MEU CÓDIGO:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim num1 As Double

Dim num2 As Double

Dim num3 As Double

Dim num4 As Double

Dim num5 As Double

Dim num6 As Double

Dim num7 As Double

Dim num8 As Double

Dim num9 As Double

Dim num10 As Double

Dim num11 As Double

Dim num12 As Double

Dim num13 As Double

Dim num14 As Double

Dim num15 As Double

Dim num16 As Double

Dim num17 As Double

Dim num18 As Double

Dim num19 As Double

Dim num20 As Double

Dim num21 As Double

Dim num22 As Double

Dim num23 As Double

Dim num24 As Double

Dim num25 As Double

num1 = TextBox15.Text

num2 = TextBox16.Text

num3 = TextBox17.Text

num4 = Val(TextBox18.Text)

num5 = Val(TextBox20.Text)

TextBox21.Text = num1 * num2 * num3 * (num4 + num5) * 0.0000525

num6 = TextBox22.Text

num7 = TextBox23.Text

num8 = TextBox24.Text

num9 = Val(TextBox25.Text)

num10 = Val(TextBox26.Text)

TextBox27.Text = num6 * num7 * num8 * (num9 + num10) * 0.0000525

num11 = TextBox28.Text

num12 = TextBox29.Text

num13 = TextBox30.Text

num14 = Val(TextBox31.Text)

num15 = Val(TextBox32.Text)

TextBox33.Text = num11 * num12 * num13 * (num14 + num15) * 0.0000525

num16 = TextBox34.Text

num17 = TextBox35.Text

num18 = TextBox36.Text

num19 = Val(TextBox37.Text)

num20 = Val(TextBox38.Text)

TextBox39.Text = num16 * num17 * num18 * (num19 + num20) * 0.0000525

num21 = TextBox40.Text

num22 = TextBox41.Text

num23 = TextBox42.Text

num24 = Val(TextBox43.Text)

num25 = Val(TextBox44.Text)

TextBox45.Text = num21 * num22 * num23 * (num24 + num25) * 0.0000525

TOTAL_A_PAGARTextBox.Text = CDbl(TextBox21.Text) + CDbl(TextBox27.Text) + CDbl(TextBox33.Text) + CDbl(TextBox39.Text) + CDbl(TextBox45.Text)

==============================================================================

ENTÃO, COM ESTA APLICAÇÃO, QUANDO EM EXCUÇÃO EU NÃO CONSIGO CALCULAR, CASO FIQUE ALGUMA TEXTBOX VAZIA, DA ERRO E FECHA O APLICATIO.

MAS SE COMPLETO TODAS TEXTBOX A APLICAÇÃO CALCULA CORRETAMENTE.

alguém SABERIA COMO POSSO RESOLVER ISTO !

Editado por regfsd
Link para o comentário
Compartilhar em outros sites

5 respostass a esta questão

Posts Recomendados

  • 0

---------------------------------------------------------------------------------------------------------------------------------------------

COM AJUDA DE UM AMIGO, CONSEGUI RESOLVER ASSIM:

If TextBox15.Text = "" Then TextBox15.Text = "0"

If TextBox16.Text = "" Then TextBox16.Text = "0"

If TextBox17.Text = "" Then TextBox17.Text = "0"

If TextBox18.Text = "" Then TextBox18.Text = "0"

If TextBox20.Text = "" Then TextBox20.Text = "0"

If TextBox22.Text = "" Then TextBox22.Text = "0"

If TextBox23.Text = "" Then TextBox23.Text = "0"

If TextBox24.Text = "" Then TextBox24.Text = "0"

If TextBox25.Text = "" Then TextBox25.Text = "0"

If TextBox26.Text = "" Then TextBox26.Text = "0"

If TextBox28.Text = "" Then TextBox28.Text = "0"

If TextBox29.Text = "" Then TextBox29.Text = "0"

If TextBox30.Text = "" Then TextBox30.Text = "0"

If TextBox31.Text = "" Then TextBox31.Text = "0"

If TextBox32.Text = "" Then TextBox32.Text = "0"

If TextBox34.Text = "" Then TextBox34.Text = "0"

If TextBox35.Text = "" Then TextBox35.Text = "0"

If TextBox36.Text = "" Then TextBox36.Text = "0"

If TextBox37.Text = "" Then TextBox37.Text = "0"

If TextBox38.Text = "" Then TextBox38.Text = "0"

If TextBox40.Text = "" Then TextBox40.Text = "0"

If TextBox41.Text = "" Then TextBox41.Text = "0"

If TextBox42.Text = "" Then TextBox42.Text = "0"

If TextBox43.Text = "" Then TextBox43.Text = "0"

If TextBox44.Text = "" Then TextBox44.Text = "0"

Link para o comentário
Compartilhar em outros sites

Participe da discussão

Você pode postar agora e se registrar depois. Se você já tem uma conta, acesse agora para postar com sua conta.

Visitante
Responder esta pergunta...

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emoticons são permitidos.

×   Seu link foi incorporado automaticamente.   Exibir como um link em vez disso

×   Seu conteúdo anterior foi restaurado.   Limpar Editor

×   Você não pode colar imagens diretamente. Carregar ou inserir imagens do URL.



  • Estatísticas dos Fóruns

    • Tópicos
      152,2k
    • Posts
      651,9k
×
×
  • Criar Novo...