Criar uma DIM para ...
 
Notifications
Clear all

Criar uma DIM para formulario escolhido

18 Posts
2 Usuários
0 Reactions
3,749 Visualizações
(@fazerbem)
Posts: 0
New Member
Topic starter
 

tenho o seguinte codigo abaixo, onde Caixa1 é um formulario. Porem tenho ainda os formularios Caixa2, Caixa3, Caixa4 e Caixa5. Para cada formulario desses utilizei a propriedade ShowModal = False.
Meus caixas 1 a 5 funcionam como um Comander. ou seja posso realizar e atender ate 5 clientes ao mesmo tempo.
Para isso em cada Caixa de 1 a 5, eu criei 5 botoes de comando que ao clicado chama cada caixa especifico sem fechar os outros.

Estando em qualquer formulario dos caixas de 1 a 5, para processar a venda eu chamo obrigatoriamente outro formulario de nome XPagamento2, pois este serve a todos os caixas de 1 a 5, onde escolho a forma de pagamento e ao processar, joga as informacoes nas Caption e Values do caixa ativo. Note que abaixo esta Caixa2 como sendo a referencia do caixa.

Minha pergunta é :

Como eu faco para criar uma DIm em que o Caixa a ser usado no comando irá depender do que estiver dentro de uma TextBox ?

Tentei usar isso :

Dim Ativo As String
Ativo = XPagamento.caixa.Value ' caixa é uma textbox do formulario Xpagamento, pois nos formularios Caixa 1 a 5 eu possuo uma TextBox ao qual esta fixado "Caixa1" para o formulario Caixa1, "Caixa2"para o formulario Caixa2, e assim sucessivamente. Pois assim dentro do Formulario XPagamento2, na TextBox Caixa.Value , ira aparecer conforme o caixa ativo.

Sendo assim, ao usar a DIM acima da erro, Se , Ativo = XPagamento.caixa.Value onde esta o erro ???

Se eu por assim por exemplo nao da erro:

Caixa2.Forma_Pag.Caption = Myoption

Private Sub btnOK1_Click()
    Application.ScreenUpdating = 0
Dim Valor As String
Dim Opt As String
Dim Myoption As String

  If Opt1.Value = True Then 'Dinheiro
  Myoption = "DINHEIRO"
  Troco.Show
  If TextBox3.Value <> "" Then
  Caixa2.Label_2.Caption = Format(TextBox3.Value, "R$ #,##0.00")
  End If
  
  GoTo Segue
End If
  If Opt2.Value = True Then 'Deposito
  Myoption = "DEPÓSITO"
    If TextBox3.Value <> "" Then
  Caixa2.Label_2.Caption = Format(TextBox3.Value, "R$ #,##0.00")
  End If
  GoTo Segue
End If
  If Opt3.Value = True Then  'Pendencia
  Myoption = "PENDÊNCIA"
    If TextBox3.Value <> "" Then
  Caixa2.Label_2.Caption = Format(TextBox3.Value, "R$ #,##0.00")
  End If
  GoTo Segue
End If
  If Opt4.Value = True Then  'Dinheiro + Debito
  Myoption = "DINHEIRO + DÉBITO"
  Caixa2.Label_3.Caption = TextBox15.Value
  Caixa2.Label_4.Caption = TextBox13.Value

  Caixa2.Label_9.Caption = TextBox8.Value * Plan34.Range("I11").Value
  GoTo Segue
End If
  If Opt5.Value = True Then  'Dinheiro + Cartao 1X
  Myoption = "DINHEIRO + CARTÃO 1x"
  Caixa2.Label_3.Caption = TextBox15.Value
    Caixa2.Label_4.Caption = TextBox13.Value

  Caixa2.Label_9.Caption = TextBox8.Value * Plan34.Range("I11").Value
  GoTo Segue
End If
  If Opt6.Value = True Then  'Dinheiro + Cartao 2x
  Myoption = "DINHEIRO + CARTÃO 2x"
  Caixa2.Label_3.Caption = TextBox15.Value
    Caixa2.Label_4.Caption = TextBox13.Value

   Caixa2.Label_9.Caption = TextBox8.Value * Plan34.Range("I11").Value
  GoTo Segue
End If
  If Opt7.Value = True Then  'Dinheiro + Cartao 3x
  Myoption = "DINHEIRO + CARTÃO 3x"
  Caixa2.Label_3.Caption = TextBox15.Value
    Caixa2.Label_4.Caption = TextBox13.Value
      Caixa2.Label_9.Caption = TextBox7.Value
  Caixa2.Label_9.Caption = TextBox8.Value * Plan34.Range("I11").Value
  GoTo Segue
End If
  If Opt8.Value = True Then   'Debito
  Myoption = "DÉBITO"
  Caixa2.Label_3.Caption = Format(TextBox8.Value, "R$ #,##0.00")
  Caixa2.Label_9.Caption = TextBox8.Value * Plan34.Range("H11").Value
  
'  End If
GoTo Segue
End If
  If Opt9.Value = True Then  'Credito 1x
  Myoption = "CRÉDITO 1x"
 '   If TextBox3.Value <> "" Then
  Caixa2.Label_2.Caption = Format(TextBox3.Value, "R$ #,##0.00")
  Caixa2.Label_9.Caption = TextBox8.Value * Plan34.Range("I11").Value
  'End If
  GoTo Segue
End If
  If Opt10.Value = True Then  'Credito 2x
  Myoption = "CRÉDITO 2x"
'    If TextBox3.Value <> "" Then
  Caixa2.Label_2.Caption = Format(TextBox3.Value, "R$ #,##0.00")
  Caixa2.Label_9.Caption = TextBox8.Value * Plan34.Range("I11").Value
  
  'End If
  GoTo Segue
End If
  If Opt11.Value = True Then  'Credito 3X
  Myoption = "CRÉDITO 3x"
 '   If TextBox3.Value <> "" Then
  Caixa2.Label_2.Caption = Format(TextBox3.Value, "R$ #,##0.00")
  Caixa2.Label_9.Caption = TextBox8.Value * Plan34.Range("I11").Value
  
  'End If
  GoTo Segue
End If

'If Opt4.Value = True Or Opt5.Value = True Or Opt6.Value = Ture Or Opt7.Value = True Then
'If TextBox16.Value = "" Then
Mensagem4.Show
Exit Sub
'End If
'End If

If TextBox17 <> "" Then
GoTo Segue
End If

If Myoption = "" Then
Mensagem1.Show

Exit Sub
End If

Troco.Show
Exit Sub

Segue:

Caixa2.Forma_Pag.Caption = Myoption
Caixa2.PAGAMENTO.Caption = "PROCESSAR A VENDA"
Caixa2.PAGAMENTO.BackColor = &HC000&
Caixa2.PAGAMENTO.ForeColor = &HFFFFFF

If Myoption = "PENDÊNCIA" Then
Caixa2.Total = ""
End If
Caixa2.Total.Value = TextBox8.Value



'Caixa2.Label_6 = Format((Caixa2.Total.Value - Caixa2.Label_9.Caption) - Caixa2.Label_8.Caption, "R$ #,##0.00")

'---------------------------------------------------------------------

Caixa2.Label_1.Caption = TextBox1.Value


Unload Me

    Application.ScreenUpdating = 1
End Sub
 
Postado : 11/01/2017 8:28 pm
(@fazerbem)
Posts: 0
New Member
Topic starter
 

Segue Planilha acima corrigida !

 
Postado : 18/01/2017 8:33 pm
(@fazerbem)
Posts: 0
New Member
Topic starter
 

Ola, alguem teria alguma sigestao?

Grato

Andre

 
Postado : 20/01/2017 8:15 pm
(@fazerbem)
Posts: 0
New Member
Topic starter
 

Boa Noite

Resolvi colocando If mesmo, ficou bem maior o codigo, pois sao 5 caixas, mas o importante é funcionar.

Grato

Andre

 
Postado : 22/01/2017 5:39 pm
Página 2 / 2