Notifications
Clear all

Variaveis

23 Posts
3 Usuários
0 Reactions
4,822 Visualizações
(@fazerbem)
Posts: 0
New Member
Topic starter
 

Tenho 5 caixas que podem estar abertos simultaneamente, pois a Propriedade SHOWMODAL = False
Todos os caixas deverao chamar o formulario XPagamento quando necessario , pois este é temporario .

Onde estaria o erro aqui ?

Dentro do Formulario - XPagameto.Caixa.Value= Caixa 1 ' pode estar escrito dentro da TextBox ( Caixa ) : Caixa1, Caixa2, Caixa3, Caixa4 ou Caixa5

Este comando abaixo esta dentro de um botao dentro do Formulario XPagamento e o mesmo ira lancar informacoes dependendo da Variavel em questao.

Private Sub Teste_Click()
Dim CaixaAtivo As String
CaixaAtivo= XPagameto.Caixa.Value

CaixaAtivo.PAGAMENTO.Caption = "FORMA DE PAGAMENTO"
CaixaAtivo.PAGAMENTO.ForeColor = vbBlack
CaixaAtivo.PAGAMENTO.BackColor = &HE0E0E0

porem assim abaixo nao da o erro

Private Sub Teste_Click()
Caixa1.PAGAMENTO.Caption = "FORMA DE PAGAMENTO"
Caixa1.PAGAMENTO.ForeColor = vbBlack
Caixa1.PAGAMENTO.BackColor = &HE0E0E0

O erro que da é esse

Erro de Compilacao
Qualificador Invalido

Por favor preciso mesmo resolver isso

Grato

Andre

 
Postado : 04/02/2017 4:40 pm
(@fazerbem)
Posts: 0
New Member
Topic starter
 

Nao sei ainda como implantar neste codigo abaixo.

Repare que meu codigo possui 5 rotinas identicas para cada Caixa de 1 a 5, na intensao de enxugar este codigo e manter apenas uma rotina para todos os caixas , tenho que ao inves disso:

Caixa1.Txt_Pendencia.Value = 2

ter isso

Ativo.Txt_Pendencia.Value = 2

Entao Ativo podera ser = Caixa1, ou Caixa 2 ou Caixa 3 ou Caixa 4 ou Caixa 5, dependendo do que esta escrito em :

TextBox1.Value dentro do Formulario Pagamento2, pois esse codigo abaixo é processado dentro de Pagamento2 , e jogara as informacoes processadas no caixa referenciado em ATIVO = TextBox1.Value.

Sera que expliquei corretamente ?

por isso e que tentei criar a variavel

Dim Ativo As String
Ativo = TextBox1.Value

Segue meu codigo ao qual funciona perfeitamente, porem usando varios If's

Private Sub btnOK1_Click()
    Application.ScreenUpdating = 0
Dim valor As String
Dim Opt As String
Dim Myoption As String
'Jogar o Desconto para Caixa1
Dim Valor1, Valor2 As Double

'--------------------------------------------------------------------
' Rotina para CAixa1

If Caixa.Value = "Caixa1" Then

  If Opt1.Value = True Then 'Dinheiro
  Myoption = "DINHEIRO"
  Caixa1.Txt_Pendencia.Value = 2
  Troco.Show
   
  If TextBox3.Value <> "" Then
  Caixa1.Label_2.Caption = Format(TextBox3.Value, "R$ #,##0.00")
  End If
  
  GoTo Segue1
End If
  If Opt2.Value = True Then 'Deposito
  Myoption = "DEPÓSITO"
  Caixa1.Txt_Pendencia.Value = 3
  
    If TextBox3.Value <> "" Then
  Caixa1.Label_2.Caption = Format(TextBox3.Value, "R$ #,##0.00")
  End If
  GoTo Segue1
End If
  If Opt3.Value = True Then  'Pendencia
  Myoption = "PENDÊNCIA"
  Caixa1.Txt_Pendencia.Value = 4
  Caixa1.Label_10.Caption = TextBox8.Value
  Caixa1.Label_11.Caption = TextBox21.Value
  
    If TextBox3.Value <> "" Then
  Caixa1.Label_2.Caption = Format(TextBox3.Value, "R$ #,##0.00")
  End If
  GoTo Segue1
End If
  If Opt4.Value = True Then  'Dinheiro + Debito
  Myoption = "DINHEIRO + DÉBITO"
  Caixa1.Txt_Pendencia.Value = 5
  
  Caixa1.Label_3.Caption = TextBox15.Value
  Caixa1.Label_4.Caption = TextBox13.Value

  Caixa1.Label_9.Caption = TextBox15.Value * Plan18.Range("F31").Value
  GoTo Segue1
End If
  If Opt5.Value = True Then  'Dinheiro + Cartao 1X
  Myoption = "DINHEIRO + CARTÃO 1x"
  Caixa1.Txt_Pendencia.Value = 6
  
  Caixa1.Label_3.Caption = TextBox15.Value
    Caixa1.Label_4.Caption = TextBox13.Value

  Caixa1.Label_9.Caption = TextBox15.Value * Plan18.Range("G31").Value
  GoTo Segue1
End If
  If Opt6.Value = True Then  'Dinheiro + Cartao 2x
  Myoption = "DINHEIRO + CARTÃO 2x"
  Caixa1.Txt_Pendencia.Value = 7
  
  Caixa1.Label_3.Caption = TextBox15.Value
    Caixa1.Label_4.Caption = TextBox13.Value

   Caixa1.Label_9.Caption = TextBox15.Value * Plan18.Range("H31").Value
  GoTo Segue1
End If
  If Opt7.Value = True Then  'Dinheiro + Cartao 3x
  Myoption = "DINHEIRO + CARTÃO 3x"
  Caixa1.Txt_Pendencia.Value = 8
  
  Caixa1.Label_3.Caption = TextBox15.Value
    Caixa1.Label_4.Caption = TextBox13.Value
      Caixa1.Label_9.Caption = TextBox7.Value
  Caixa1.Label_9.Caption = TextBox15.Value * Plan18.Range("I31").Value
  GoTo Segue1
End If
  If Opt8.Value = True Then   'Debito
  Myoption = "DÉBITO"
  Caixa1.Txt_Pendencia.Value = 9
  
  Caixa1.Label_3.Caption = Format(TextBox8.Value, "R$ #,##0.00")
  Caixa1.Label_9.Caption = TextBox8.Value * Plan18.Range("F31").Value
  
'  End If
GoTo Segue1
End If


  If Opt9.Value = True Then  'Credito 1x
  Myoption = "CRÉDITO 1x"
  Caixa1.Txt_Pendencia.Value = 10
  
 '   If TextBox3.Value <> "" Then
  Caixa1.Label_2.Caption = Format(TextBox3.Value, "R$ #,##0.00")
   Caixa1.Label_9.Caption = TextBox8.Value * Plan18.Range("G31").Value
 
  'End If
  GoTo Segue1
End If
  If Opt10.Value = True Then  'Credito 2x
  Myoption = "CRÉDITO 2x"
  Caixa1.Txt_Pendencia.Value = 11
  
'    If TextBox3.Value <> "" Then
  Caixa1.Label_2.Caption = Format(TextBox3.Value, "R$ #,##0.00")
  Caixa1.Label_9.Caption = TextBox8.Value * Plan18.Range("H31").Value
 
  'End If
  GoTo Segue1
End If
  If Opt11.Value = True Then  'Credito 3X
  Myoption = "CRÉDITO 3x"
  Caixa1.Txt_Pendencia.Value = 12
  
 '   If TextBox3.Value <> "" Then
  Caixa1.Label_2.Caption = Format(TextBox3.Value, "R$ #,##0.00")
  Caixa1.Label_9.Caption = TextBox8.Value * Plan18.Range("I31").Value
  
  'End If
  GoTo Segue1
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 Segue1
End If

If Myoption = "" Then
Mensagem1.Show

Exit Sub
End If

Troco.Show
Exit Sub

Segue1:

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

If Myoption = "PENDÊNCIA" Then
Caixa1.Total = ""
End If

'Força haver uma modificacao em Caixa1.Total e assim chamar outra rotina.
Caixa1.Total.Value = ""

Caixa1.Total.Value = TextBox8.Value
Caixa1.Label_1.Caption = TextBox1.Value

'Sheets(D).fff

'Jogar o Desconto para Caixa1
Valor1 = TextBox5.Value
Valor2 = TextBox6.Value
Caixa1.TextBox_Desconto = Valor1 + Valor2

GoTo Fim:

End If
'--------------------------------------------------------------------

'--------------------------------------------------------------------
' Rotina para o caixa 2
If Caixa.Value = "Caixa2" Then

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

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

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

   Caixa2.Label_9.Caption = TextBox8.Value * Plan34.Range("I11").Value
  GoTo Segue2
End If
  If Opt7.Value = True Then  'Dinheiro + Cartao 3x
  Myoption = "DINHEIRO + CARTÃO 3x"
  Caixa2.Txt_Pendencia.Value = 8
  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 Segue2
End If
  If Opt8.Value = True Then   'Debito
  Myoption = "DÉBITO"
  Caixa2.Txt_Pendencia.Value = 9
  Caixa2.Label_3.Caption = Format(TextBox8.Value, "R$ #,##0.00")
  Caixa2.Label_9.Caption = TextBox8.Value * Plan34.Range("H11").Value
  
'  End If
GoTo Segue2
End If
  If Opt9.Value = True Then  'Credito 1x
  Myoption = "CRÉDITO 1x"
  Caixa2.Txt_Pendencia.Value = 10
 '   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 Segue2
End If
  If Opt10.Value = True Then  'Credito 2x
  Myoption = "CRÉDITO 2x"
  Caixa2.Txt_Pendencia.Value = 11
'    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 Segue2
End If
  If Opt11.Value = True Then  'Credito 3X
  Myoption = "CRÉDITO 3x"
  Caixa2.Txt_Pendencia.Value = 12
 '   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 Segue2
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 Segue2
End If

If Myoption = "" Then
Mensagem1.Show

Exit Sub
End If

Troco.Show
Exit Sub

Segue2:

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

'Força haver uma modificacao em Caixa1.Total e assim chamar outra rotina.
Caixa2.Total.Value = ""

Caixa2.Total.Value = TextBox8.Value
Caixa2.Label_1.Caption = TextBox1.Value

'Jogar o Desconto para Caixa1
Valor1 = TextBox5.Value
Valor2 = TextBox6.Value
Caixa2.TextBox_Desconto = Valor1 + Valor2


GoTo Fim:

End If


'--------------------------------------------------------------------
' Rotina para o caixa 3
If Caixa.Value = "Caixa3" Then

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

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

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

   Caixa3.Label_9.Caption = TextBox8.Value * Plan34.Range("I11").Value
  GoTo Segue3
End If
  If Opt7.Value = True Then  'Dinheiro + Cartao 3x
  Myoption = "DINHEIRO + CARTÃO 3x"
  Caixa3.Txt_Pendencia.Value = 8
  Caixa3.Label_3.Caption = TextBox15.Value
    Caixa3.Label_4.Caption = TextBox13.Value
      Caixa3.Label_9.Caption = TextBox7.Value
  Caixa3.Label_9.Caption = TextBox8.Value * Plan34.Range("I11").Value
  GoTo Segue3
End If
  If Opt8.Value = True Then   'Debito
  Myoption = "DÉBITO"
  Caixa3.Txt_Pendencia.Value = 9
  Caixa3.Label_3.Caption = Format(TextBox8.Value, "R$ #,##0.00")
  Caixa3.Label_9.Caption = TextBox8.Value * Plan34.Range("H11").Value
  
'  End If
GoTo Segue3
End If
  If Opt9.Value = True Then  'Credito 1x
  Myoption = "CRÉDITO 1x"
  Caixa3.Txt_Pendencia.Value = 10
 '   If TextBox3.Value <> "" Then
  Caixa3.Label_2.Caption = Format(TextBox3.Value, "R$ #,##0.00")
  Caixa3.Label_9.Caption = TextBox8.Value * Plan34.Range("I11").Value
  'End If
  GoTo Segue3
End If
  If Opt10.Value = True Then  'Credito 2x
  Myoption = "CRÉDITO 2x"
  Caixa3.Txt_Pendencia.Value = 11
'    If TextBox3.Value <> "" Then
  Caixa3.Label_2.Caption = Format(TextBox3.Value, "R$ #,##0.00")
  Caixa3.Label_9.Caption = TextBox8.Value * Plan34.Range("I11").Value
  
  'End If
  GoTo Segue3
End If
  If Opt11.Value = True Then  'Credito 3X
  Myoption = "CRÉDITO 3x"
  Caixa3.Txt_Pendencia.Value = 12
 '   If TextBox3.Value <> "" Then
  Caixa3.Label_2.Caption = Format(TextBox3.Value, "R$ #,##0.00")
  Caixa3.Label_9.Caption = TextBox8.Value * Plan34.Range("I11").Value
  
  'End If
  GoTo Segue3
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 Segue3
End If

If Myoption = "" Then
Mensagem1.Show

Exit Sub
End If

Troco.Show
Exit Sub

Segue3:

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

If Myoption = "PENDÊNCIA" Then
Caixa3.Total = ""
End If

'Força haver uma modificacao em Caixa1.Total e assim chamar outra rotina.
Caixa3.Total.Value = ""

Caixa3.Total.Value = TextBox8.Value
Caixa3.Label_1.Caption = TextBox1.Value

GoTo Fim:

End If

'--------------------------------------------------------------------
' Rotina para o caixa 4
If Caixa.Value = "Caixa4" Then

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

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

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

   Caixa4.Label_9.Caption = TextBox8.Value * Plan34.Range("I11").Value
  GoTo Segue4
End If
  If Opt7.Value = True Then  'Dinheiro + Cartao 3x
  Myoption = "DINHEIRO + CARTÃO 3x"
  Caixa4.Txt_Pendencia.Value = 8
  Caixa4.Label_3.Caption = TextBox15.Value
    Caixa4.Label_4.Caption = TextBox13.Value
      Caixa4.Label_9.Caption = TextBox7.Value
  Caixa4.Label_9.Caption = TextBox8.Value * Plan34.Range("I11").Value
  GoTo Segue4
End If
  If Opt8.Value = True Then   'Debito
  Myoption = "DÉBITO"
  Caixa4.Txt_Pendencia.Value = 9
  Caixa4.Label_3.Caption = Format(TextBox8.Value, "R$ #,##0.00")
  Caixa4.Label_9.Caption = TextBox8.Value * Plan34.Range("H11").Value
  
'  End If
GoTo Segue4
End If
  If Opt9.Value = True Then  'Credito 1x
  Myoption = "CRÉDITO 1x"
  Caixa4.Txt_Pendencia.Value = 10
 '   If TextBox3.Value <> "" Then
  Caixa4.Label_2.Caption = Format(TextBox3.Value, "R$ #,##0.00")
  Caixa4.Label_9.Caption = TextBox8.Value * Plan34.Range("I11").Value
  'End If
  GoTo Segue4
End If
  If Opt10.Value = True Then  'Credito 2x
  Myoption = "CRÉDITO 2x"
  Caixa4.Txt_Pendencia.Value = 11
'    If TextBox3.Value <> "" Then
  Caixa4.Label_2.Caption = Format(TextBox3.Value, "R$ #,##0.00")
  Caixa4.Label_9.Caption = TextBox8.Value * Plan34.Range("I11").Value
  
  'End If
  GoTo Segue4
End If
  If Opt11.Value = True Then  'Credito 3X
  Myoption = "CRÉDITO 3x"
  Caixa4.Txt_Pendencia.Value = 12
 '   If TextBox3.Value <> "" Then
  Caixa4.Label_2.Caption = Format(TextBox3.Value, "R$ #,##0.00")
  Caixa4.Label_9.Caption = TextBox8.Value * Plan34.Range("I11").Value
  
  'End If
  GoTo Segue4
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 Segue4
End If

If Myoption = "" Then
Mensagem1.Show

Exit Sub
End If

Troco.Show
Exit Sub

Segue4:

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

If Myoption = "PENDÊNCIA" Then
Caixa4.Total = ""
End If

'Força haver uma modificacao em Caixa1.Total e assim chamar outra rotina.
Caixa4.Total.Value = ""

Caixa4.Total.Value = TextBox8.Value
Caixa4.Label_1.Caption = TextBox1.Value

GoTo Fim:

End If

'--------------------------------------------------------------------
' Rotina para o caixa 5
If Caixa.Value = "Caixa5" Then

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

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

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

   Caixa5.Label_9.Caption = TextBox8.Value * Plan34.Range("I11").Value
  GoTo Segue5
End If
  If Opt7.Value = True Then  'Dinheiro + Cartao 3x
  Myoption = "DINHEIRO + CARTÃO 3x"
  Caixa5.Txt_Pendencia.Value = 8
  Caixa5.Label_3.Caption = TextBox15.Value
    Caixa5.Label_4.Caption = TextBox13.Value
      Caixa5.Label_9.Caption = TextBox7.Value
  Caixa5.Label_9.Caption = TextBox8.Value * Plan34.Range("I11").Value
  GoTo Segue5
End If
  If Opt8.Value = True Then   'Debito
  Myoption = "DÉBITO"
  Caixa5.Txt_Pendencia.Value = 9
  Caixa5.Label_3.Caption = Format(TextBox8.Value, "R$ #,##0.00")
  Caixa5.Label_9.Caption = TextBox8.Value * Plan34.Range("H11").Value
  
'  End If
GoTo Segue5
End If
  If Opt9.Value = True Then  'Credito 1x
  Myoption = "CRÉDITO 1x"
  Caixa5.Txt_Pendencia.Value = 10
 '   If TextBox3.Value <> "" Then
  Caixa5.Label_2.Caption = Format(TextBox3.Value, "R$ #,##0.00")
  Caixa5.Label_9.Caption = TextBox8.Value * Plan34.Range("I11").Value
  'End If
  GoTo Segue5
End If
  If Opt10.Value = True Then  'Credito 2x
  Myoption = "CRÉDITO 2x"
  Caixa5.Txt_Pendencia.Value = 11
'    If TextBox3.Value <> "" Then
  Caixa5.Label_2.Caption = Format(TextBox3.Value, "R$ #,##0.00")
  Caixa5.Label_9.Caption = TextBox8.Value * Plan34.Range("I11").Value
  
  'End If
  GoTo Segue5
End If
  If Opt11.Value = True Then  'Credito 3X
  Myoption = "CRÉDITO 3x"
  Caixa5.Txt_Pendencia.Value = 12
 '   If TextBox3.Value <> "" Then
  Caixa5.Label_2.Caption = Format(TextBox3.Value, "R$ #,##0.00")
  Caixa5.Label_9.Caption = TextBox8.Value * Plan34.Range("I11").Value
  
  'End If
  GoTo Segue5
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 Segue5
End If

If Myoption = "" Then
Mensagem1.Show

Exit Sub
End If

Troco.Show
Exit Sub

Segue5:

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

If Myoption = "PENDÊNCIA" Then
Caixa5.Total = ""
End If

'Força haver uma modificacao em Caixa1.Total e assim chamar outra rotina.
Caixa5.Total.Value = ""

Caixa5.Total.Value = TextBox8.Value
Caixa5.Label_1.Caption = TextBox1.Value

End If

Fim:


Unload Me

    Application.ScreenUpdating = 1
End Sub
 
Postado : 09/03/2017 7:03 pm
(@fazerbem)
Posts: 0
New Member
Topic starter
 

Pessoa alguma nova sugestao deste meu tema ?

Grato

 
Postado : 14/03/2017 5:23 pm
(@fazerbem)
Posts: 0
New Member
Topic starter
 

Experimente utilizar VBA.UserForms(0).Txt_Caixa.Text = TextBox2.Value

Reinaldo, seu sistema funcionou , conforme eu gostaria sim, mas tem este detalhe abaixo:

1- Ao abrir o formulario, perceba que abre primeiro o Caixa 1, este ao clicar em ENTER, chama o formulario "PAGAMENTO", e ao Clicar em "PROCESSAR", manda o "OK" para o caixa1, ate aqui beleza !

2- Ao clicar no Caixa 1 Para abrir o Caixa 2, note que o formulario Caixa 1 e 2 vao estar ativos, mas o Formulario "PAGAMENTO" agora sera chamado pelo CAIXA2. Ao precionar o Botao Processar, do formulario Pagamento, nao se dará o "OK"no Caixa 2 e sim ao caixa1. Aqui tem um erro, pois o OK teria que se dar no Caixa2.

3- Porem eu percebi que caso eu feche o Caixa1, ai entao o OK se da corretamente no Caixa2, mas sosmente se eu fechar o CAIXA1.

4- Preciso que mesmo o caixa1 estiver aberto, sendo chamado o Form PAGAMENTO pelo caixa2, o OK se de no caixa2 e nao no Caixa 1, a mesma coisa se o caixa 3 estiver aberto, o OK se de no caixa 3 se Form Pagamento for aberto pelo caixa 3.

Acho que expliquei corretamente.

Posso contar com vc ou Outro usuario aqui experirnte?

Grato

Andre

 
Postado : 15/03/2017 11:09 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Eu não utilizo essa situação, foi apenas um "palpite". Aparentemente pela sua info, retorna o formulário em ordem hierárquica/abertura; assim também não se aplica ao seu desejo; tambem não vejo motivo/funcionalidade de dois formularios abertos no mesmo local, mas isso compete a voce. Como pode ver não é simples e no momento não sei se havera possibilidadede obter seu desejo/funcionalidade
Talvez deva avaliar a possibilidade de "transformar" essa rotina Pagamento em uma função; e nos formulários caixa "chamar essa função; passando os parametros necessários

 
Postado : 15/03/2017 12:15 pm
(@fazerbem)
Posts: 0
New Member
Topic starter
 

tambem não vejo motivo/funcionalidade

Da forma que fiz, pra mim teria funcionalidade, pois ao passo que estou atendendo a um cliente e este ja inicio a colocao dos itens na ListBox, vamos que chegue outro cliente , e este primeiro resolva dar a vez ao segundo, dai eu abro o segundo caixa, mantendo o primeiro caixa com os produtos, nome do cliente e tal. Executo a venda do segundo e volto entao ao primeiro caixa .

Note que se eu fechar o caixa 1 neste processo, terei que recolocar tudo na listbox novamente, chamar o banco de dados do cliente e seleciona-lo.

Assim funciona igualzinho como em restaurante, atraves de Comander.

Enetendeu agora Reinaldo.

Entao sua linha de comando passada esta OK, so falta referenciar o caixa que chamou o Form Pagamento, para que este retorne no seu chamador e nao no caixa1, exceto se ele tiver sido chamado pelo Caixa 1.

Gostei tb desta alternativa, mas como faria se sao dois formularios diferentes ?

me manda a tabela com essa modificacao pra eu entender aqui

 
Postado : 15/03/2017 12:24 pm
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Comandas são salvas em "algum lugar" a medida que vão sendo implementadas/preenchidas, assim no caixa "apenas" chamam o numero da mesma e retorna a composição/custo da mesma.Talvez possa ser mais uma opção para você analisar a possibilidade de uso/implementação.
Propus que avalie "a possibilidade de", não estudei seu código/rotinas para montar/efetuar "essa função"

 
Postado : 15/03/2017 12:41 pm
(@fazerbem)
Posts: 0
New Member
Topic starter
 

tentarei entao fazer assim e salvar as informacoes numa planilha, se conseguir aqui te aviso, meu medo é aumentar o tempo de processamento e a mesma ficar mais demorada. Da forma que fiz esta muita rapida.

ou sera que seria possivel entao minimizar o Caixa1 para que o caixa 2 ficasse como o ativo principal ?

pois vai dar um trabalhao, pois terei que transferri os itens da Listview para a planilha e depois da planilha para a listview quando voltar ao caixa

Se nao deixo como esta mesmo, fazendo varias rotinas dentro da mesma Sub, uma para cada caixa, conforme exemplo baixo

Private Sub btnOK1_Click()
Application.ScreenUpdating = 0
Dim valor As String
Dim Opt As String
Dim Myoption As String
'Jogar o Desconto para Caixa1
Dim Valor1, Valor2 As Double

'--------------------------------------------------------------------
' Rotina para o caixa 1

If Caixa.Value = "Caixa1" Then

If Opt1.Value = True Then 'Dinheiro
Myoption = "DINHEIRO"
Caixa1.Txt_Pendencia.Value = 2
Troco.Show

If TextBox3.Value <> "" Then ......

'--------------------------------------------------------------------
' Rotina para o caixa 2

If Caixa.Value = "Caixa2" Then

If Opt1.Value = True Then 'Dinheiro
Myoption = "DINHEIRO"
Caixa2.Txt_Pendencia.Value = 2
Troco.Show

If TextBox3.Value <> "" Then ......

E assim vai .....

Ja viu entao que meu codigo ficou enorme, mas funciona,.

Problema que quando tenho que implantar algo, tenho que mexer em todas as rotinas.

E daquele jeito que vc fez, Reinaldo, Faria apenas uma unica rotina.

 
Postado : 15/03/2017 12:53 pm
(@fazerbem)
Posts: 0
New Member
Topic starter
 

Venho novamente aqui para expor um problema, mas neste caso um problema que resolvi por mim mesmo após quebra muito a cabeça.
Resolvi de uma forma muito simples.

Gostaria de poder assim contribuir e deixar aqui a única solução encontrada.

Agradeço a todos que se empenharam em poder ajudar de uma forma ou outra.

Mas no final em fim consegui enxugar em muito meu codigo, pois para cada caixa usava Ifs.

Sei que aqui existem muitos Experts aos quais estao sempre me ajudando, mas a cada dia aprendemos algo e nunca sabemos tudo.

Segue abaixo a planilha modelo solucionada.

Vou deixar o topico em aberto para quaisquer outra coisa.

Andre

 
Postado : 17/03/2017 11:56 am
Página 2 / 2