Notifications
Clear all

Variaveis

23 Posts
3 Usuários
0 Reactions
4,821 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
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Esta questão não teria a ver com o tópico que já deu como Resolvido ? : viewtopic.php?f=23&t=23177&start=10

Apesar de não ter entendido direito, pois não sei que tipo de Controle é "Caixa1", mas se está utilizando a propriedade Caption vou supor que é um Controle Label, então para preencher o Label de Name "Caixa1" em um outro formulário chamado "Pagamento" o correto seria o seguinte :

Private Sub Teste_Click()
    Dim CaixaAtivo As String
    CaixaAtivo = XPagameto.Caixa.Value
    
    PAGAMENTO.Controls(CaixaAtivo).Caption = "FORMA DE PAGAMENTO"
    PAGAMENTO.Controls(CaixaAtivo).ForeColor = vbBlack
    PAGAMENTO.Controls(CaixaAtivo).BackColor = &HE0E0E0

End Sub

[]s

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

Caixa1, é justamente o nome do formulario ao qual o Formulario XPagamento ira transportar os dados.

vou explicar com mais detalhes .

Seguinte

A tela de CAIXA1, é o nome do formulario, se acionada insiro os produtos na ListView e ao precionar o Botao Forma de Pagamento, o formualrio Caixa1, ou caixa2... conforme o que estiver ativo, permanece aberto , pois usa a propriedade ShowModal = False, sendo assim abre o Formulario XPagamento2, portanto ficando os 2 formularios abertos.
Estando no Formulario XPgamento2 , ao precionar o botao confirmar, é chamada uma rotina ao qual todos os valores que estiverem na TextBox deste Formulario serao redirecionados ao Formulario Caixa1, ou caixa2 ... conforme o caso.

Veja que na figura abaixo, existem 9 textbox acima de Propriedades Caixa1, neles é que serao transportados os valores vindos do formulario XPagamento2.

Porem se eu estiver com o caixa1 e caixa2 abertos, como o Formulario XPagamento2 ira saber para qual caixa irá transportar os valores ?
Por isso preciso que o Formulario XPagamento2 identifique qual caixa veio a solicitacao.

Para isso toda vez que estou em algum caixa, ao precionar o botao Forma de Pagamento, é lancado em Xpagamento2 numa TextBox chamada Caixa.Value o seguinte texto: Caixa1 se eu estiver no caixa 1, Caixa2 se eu etiver no caixa2....

Se eu estiver no Caixa 1 , entao, XPagamento2.Caixa.Value = "Caixa1"
Se eu estiver no Caixa 2 , entao, XPagamento2.Caixa.Value = "Caixa2"
Se eu estiver no Caixa 3 , entao, XPagamento2.Caixa.Value = "Caixa3"

Note que os caixas1 a caixa5 sao identicos ! Mas usam o Formulario XPagamento2 , pois este funciona como temporario. Sendo assim existe neste temporario uma TextBox de nome Caixa que podera estar como Caixa1, caixa2....

Bem se Tenho uma identificacao na textbox: Caixa.Value , entao ao acionar o botao confirmar ( Xpagamento2 ), ele deveria aceitar esta variavel que fiz, porem esta dando o erro ja informado.

VEja abaixo que criei no codigo esta rotina, por nao ter conseguido criar a inda a varialve, usado IFs, mas tornou o codigo muito garnde.

' Rotina para o caixa 1
If Caixa.Value = "Caixa1" Then

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

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

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

'Dim Frm
'Frm = XPagamento2.Caixa.Value                          ' Frm seria a Variavel 

'Sheets(D).D


'ABAIXO , ONDE ESTIVER ESCRITO CAIXA1 SERÁ ESCRITO A VARIAVEL FRM, pois FRM poderá ser CAIXA1, CAIXA2..... Sendo assim se por exemplo 3 formularios CAixa1, Caixa2 e Caixa 3 estiverem abertos, entao serao enviados ao caixa certo as informacoes !


'--------------------------------------------------------------------
' Rotina para o caixa 1
If Caixa.Value = "Caixa1" Then

  If Opt1.Value = True Then 'Dinheiro
  Myoption = "DINHEIRO"
  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"
    If TextBox3.Value <> "" Then
  Caixa1.Label_2.Caption = Format(TextBox3.Value, "R$ #,##0.00")
  End If
  GoTo Segue1

Segue codigo inteiro do Botao XPagamento2, usando os Varios Ifs para poder identificar o Caixa que esta ativo.

Repare que o codigo fica imenso se eu nao conseguir resolver a Variant

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

'Dim Frm
'Frm = XPagamento2.Caixa.Value

'Sheets(D).D

'--------------------------------------------------------------------
' Rotina para o caixa 1
If Caixa.Value = "Caixa1" Then

  If Opt1.Value = True Then 'Dinheiro
  Myoption = "DINHEIRO"
  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"
    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"
    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.Label_3.Caption = TextBox15.Value
  Caixa1.Label_4.Caption = TextBox13.Value

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

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

   Caixa1.Label_9.Caption = TextBox8.Value * Plan18.Range("H31").Value
  GoTo Segue1
End If
  If Opt7.Value = True Then  'Dinheiro + Cartao 3x
  Myoption = "DINHEIRO + CARTÃO 3x"
  Caixa1.Label_3.Caption = TextBox15.Value
    Caixa1.Label_4.Caption = TextBox13.Value
      Caixa1.Label_9.Caption = TextBox7.Value
  Caixa1.Label_9.Caption = TextBox8.Value * Plan18.Range("I31").Value
  GoTo Segue1
End If
  If Opt8.Value = True Then   'Debito
  Myoption = "DÉBITO"
  Caixa1.Label_3.Caption = Format(TextBox8.Value, "R$ #,##0.00")
  Caixa1.Label_9.Caption = TextBox8.Value * Plan34.Range("H11").Value
  
'  End If
GoTo Segue1
End If
  If Opt9.Value = True Then  'Credito 1x
  Myoption = "CRÉDITO 1x"
 '   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"
'    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"
 '   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
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"
  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"
    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"
    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.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.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.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.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.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"
 '   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"
'    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"
 '   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
Caixa2.Total.Value = TextBox8.Value
Caixa2.Label_1.Caption = TextBox1.Value

'Jogar o Desconto para Caixa1
Valor1 = TextBox5.Value
Valor2 = TextBox6.Value
Caixa1.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"
  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"
    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"
    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.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.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.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.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.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"
 '   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"
'    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"
 '   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
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"
  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"
    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"
    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.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.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.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.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.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"
 '   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"
'    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"
 '   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
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"
  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"
    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"
    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.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.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.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.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.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"
 '   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"
'    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"
 '   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
Caixa5.Total.Value = TextBox8.Value
Caixa5.Label_1.Caption = TextBox1.Value

End If

Fim:


Unload Me

    Application.ScreenUpdating = 1
End Sub
 
Postado : 05/02/2017 7:39 am
(@fazerbem)
Posts: 0
New Member
Topic starter
 

Dando mais enfase acima:

Tudo se resume em nao ter que colocar no codigo o nome do Caixa1 e sim a Variavel FRM< ou Caixa Ativo ou outro niome qualquer.

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

- Caixa1 'o nome do Formulario, poderia ser Caixa2 se usado.
- PAGANTO é o nome do BOTAO "FORMA DE PAGAMENTO"
- CAIXA ATIVO é a VARIANTE que poderá estar como Caixa1, Caixa2, Caixa3...
Por isso criei a Variant Caixa Ativo, porem da o erro ja informado.

 
Postado : 05/02/2017 7:48 am
(@fazerbem)
Posts: 0
New Member
Topic starter
 

Em resumo ,

como criar uma variavel que represente o nome do formulario ?

 
Postado : 05/02/2017 8:06 pm
(@fazerbem)
Posts: 0
New Member
Topic starter
 

desculpem a franquesa, mas essa foi a primeira vez que fiquei sem uma resposta aqui no forum.

So gostaria de saber se isso que estou perguntando é possivel de se fazer ou nao. Pois ja pesquisei muito e nao encontrei, nao sei se nas pesquisas estou usando o termo certo. COmo nao manjo outro idioma entao me limitei mesmo aos sites em portugues.

Sendo assim alguem poderia me responder se existe ou nao uma solucao ?

Grato

 
Postado : 08/02/2017 5:29 pm
(@fazerbem)
Posts: 0
New Member
Topic starter
 

Tento a seguir explicar de forma mais clara meu probelma.

PS : a forma que resolvi isso foi usando varios IF, mas com isso o codigo ficou grande demais e trabalhoso se tenho que altera algo.

Gostaria entao de criar a variavel e assim resumir o codigo.

digamos que eu tenha varias abas identicas e quero escolher qual aba devo chamar.
plan1, plan2, plan3, plan4, plan5

Dim nome As string
nome = range(" b1").value ' b1 é o nome dado a aba da planilha

sheets(nome).activate

isso integrado a um codigo ira funcionar ok !

mas isso acima não funciona num formulario
digamos que eu tenha 5 formularios identicos cada um com um nome, caixa1, caixa2,caixa3,caixa4 E caixa5. Quero que esses 5 caixas tenham em comum o chamamento de um unico formulario pagamento, que ira funcionar como formulario provisorio a ambos os caixa.
Estando todos os caixas em ShowModal= False ' isso fara abrir os 5 caixas ao mesmo tempo
Estando no caixa1 e E abrindo o caixa 3. Vamos que volte ao caixa 1 e execute minha macro. Esta ira chamar o formulario pagamento , apos Executar o pagamento, este carregaos dados e coloca em caixa 1 , e fecha o formulario pagamento , deixando livre , dai darei o processegmento final pelo caixa 1.
Ao abrir o caixa 3 este tb chama pagamento , volta ao caoxa 3 apos executar a macro de pagamento e o fecha liberando pagamento.

para que isso seja possivel, no retorno de pagamento para quaisquer um dos caixas, tenho que na macro em pagamento indicar qual caixa devi direcionar e colar os dados, se para caixa1, se caixa2 se caixa 3 se caixa 4 ou se caixa 5.
Por isso tentei criar isso abaixo mas da erro.

Dim caixa_ativo As String
caixa_ativo = textbox1 ' estando em quaiquer caixa, ao chamar o pagamento eu colo na textbox1 de formulario o nome do caixa em execucao - pagamento.textbox.value = caixa.textbox, onde caixa.textbox estara escrito caixa1 , e se no caixa 2 estara escrito caixa 2 e assim vai.

entao , ao executar a macro processar em pagamento, este ira transferir algumas informacoes para o caixa ativo.
para isso preciso informar ao formulario pagamento qual caixa sera o destino, pois possa ser que os 5 caixas estejam abertos.

entao apos ter criado a variavel acima pensei que colocando o codigo abaixo iria resolver meu problema.

caixa_ativo.formapagamento.value = testbox5.value

aqui da erro , portanto onde estou errando neste codigo ?

grato

andre

 
Postado : 25/02/2017 3:34 pm
(@fazerbem)
Posts: 0
New Member
Topic starter
 

Nova tentativa com erro.

Caixa1, caixa2 e caixa3 sao formularios
Sabores_Proteinas é tambem um formulario
TExtBox1 é uma textbox dentro de Sabores_Proteinas. Dentro desta TextBox irei referenciar o nome do formulario a ser usado como a variavel, podendo ser "Caixa1", "Caixa2"ou "Caixa3"

Para publicar o nome do formulario como sendo uma variavel ( em TextBox1 ), montei o codigo abaixo, mas parece que ta errado.

Alguma sugestao ?

Public Ativo As form
Ativo = Me.Sabores_Proteinas.TextBox1
_______________________________________

Private Sub OK_Click()

If Opt1.Value = True And marca.Caption = "Importados" And Ativo.Ref = 103 Then
Caixa1.Ref = 104
Myoption = "Baunilha"
GoTo Fim
End If
If Opt2.Value = True And marca.Caption = "Importados" And Ativo.Ref = 103 Then

MsgBox "Fazer oc Codigo "

GoTo Fim
End If
If Opt3.Value = True And marca.Caption = "Importados" And Ativo.Ref = 103 Then
GoTo Fim
End If

Fim:

End Sub

 
Postado : 05/03/2017 8:54 am
(@fazerbem)
Posts: 0
New Member
Topic starter
 

Segue tabela exemplo

 
Postado : 05/03/2017 9:36 am
(@fernandofernandes)
Posts: 43750
Illustrious Member
 

Talvez tenha que referenciar direto algo +/- assim:

Private Sub CommandButton1_Click()

Dim Ativo As String
Ativo = TextBox1.Value
Select Case Ativo
    Case "Caixa1"
        Caixa1.Txt_Caixa.Value = TextBox2.Value
    Case "Caixa2"
        Caixa2.Txt_Caixa.Value = TextBox2.Value
End Select
'Deixa campo vazio pra proxima venda
TextBox2.Value = ""

Unload Me

End Sub
[code][/code]
 
Postado : 09/03/2017 3:06 am
(@fazerbem)
Posts: 0
New Member
Topic starter
 

Opa Reinaldo !!, finalmente alguem me respondeu, muito obrigado mesmo !!!

Segue a planilha modelo.
Esta no Formulario.

Grato

Andre

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

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

 
Postado : 09/03/2017 1:20 pm
(@fazerbem)
Posts: 0
New Member
Topic starter
 

Reinaldo, quase la, veja que se vc usar o Caixa 1 e der ENTER , retorna o K no caixa1

Mas se nos caixas 2 ou 3 se vc der ENTER nao retorna o OK ao caixa2 nem no 3 e sim retorna sempre no caixa1 o OK.

POr isso deixei os caixas 1 a 3 na propriedade SHOWMODAL = FAlse pra os tres atuarem. Sendo assim o OK teria que ser relacionar de acordo com o caixa usado e nao somente dar retorno no caixa 1, ..

Vaelu camarada, e fico no aguardo anciosamente.

Andre

 
Postado : 09/03/2017 1:54 pm
(@teleguiado)
Posts: 0
New Member
 

Fazerbem, veja se é isso.

 
Postado : 09/03/2017 2:46 pm
(@fazerbem)
Posts: 0
New Member
Topic starter
 

Fazerbem, veja se é isso.

Exatamente isso mesmo !!! PINBA !!!!!!!!!!!!!!!!!!!!!!!!!!

ja to a meses querendo resolver isso, e tive que usar um monte de IF , dai ficou enorme meu codigo, e quando mudava algo tinha que mudar em todas as rotinas. Se entendi bem e vou agora implantar no meu trabalho original, vai funcionar da forma que eu queria, voltarei aqui pra dar o resultado.

Agradeco enormemente a vc e ao Reinaldo pela força.

Desculpem ter cobrado uma resposta ao novamente insistir neste tema. Mas como ningeum respondia fui insistindo ate aparecer vcs que responderam.

Abarcos

e ate breve com a resposta

Andre

 
Postado : 09/03/2017 3:22 pm
Página 1 / 2