- 15 Mar 2018 às 11:27
#31075
Quando insiro a data do formulario para a celula ela passa de dd/mm/aaaa para mm/dd/aaaa, não estou conseguindo corrigir, segue o codigo que estou utilizando abaixo, as textbox que se referem a data são a TextBox 4 e TextBox2
Private Sub CommandButton1_Click()
lsInserirTextBox frmCadastro, "Cadastro", 1
lsLimparTextBox frmCadastro
TextBox1.SetFocus
End Sub
Private Sub lsInserir(ByRef lTextBox As Variant, ByVal lSheet As String, ByVal lColunaCodigo As Long, ByVal lUltimaLinha As Long)
If (TypeOf lTextBox Is MSForms.TextBox) Or (TypeOf lTextBox Is MSForms.ComboBox) Then
Sheets(lSheet).Range(lTextBox.Tag & lUltimaLinha).Value = lTextBox.Text
Else
If TypeOf lTextBox Is MSForms.OptionButton Then
If lTextBox.Value = True Then
Sheets(lSheet).Range(lTextBox.Tag & lUltimaLinha).Value = lTextBox.Caption
End If
End If
End If
End Sub
Public Function lsInserirTextBox(formulario As UserForm, ByVal lSheet As String, ByVal lColunaCodigo As Long)
Dim controle As Control
Dim lUltimaLinhaAtiva As Long
lUltimaLinhaAtiva = Worksheets(lSheet).Cells(Worksheets(lSheet).Rows.Count, lColunaCodigo).End(xlUp).Row + 1
For Each controle In formulario.Controls
lsInserir controle, lSheet, lColunaCodigo, lUltimaLinhaAtiva
Next
End Function
Public Function lsLimparTextBox(formulario As UserForm)
Dim controle As Control
For Each controle In formulario.Controls
If TypeOf controle Is MSForms.TextBox Then
controle.Text = ""
End If
Next
End Function
Private Sub CommandButton2_Click()
lsLimparTextBox frmCadastro
TextBox1.SetFocus
End Sub
Private Sub Frame1_Click()
End Sub
Private Sub Label1_Click()
End Sub
Private Sub Label3_Click()
End Sub
Private Sub Label4_Click()
End Sub
Private Sub OptionButton2_Click()
End Sub
Private Sub TextBox2_Change()
End Sub
Private Sub TextBox3_Change()
End Sub
Private Sub TextBox4_Change()
End Sub
Private Sub CommandButton1_Click()
lsInserirTextBox frmCadastro, "Cadastro", 1
lsLimparTextBox frmCadastro
TextBox1.SetFocus
End Sub
Private Sub lsInserir(ByRef lTextBox As Variant, ByVal lSheet As String, ByVal lColunaCodigo As Long, ByVal lUltimaLinha As Long)
If (TypeOf lTextBox Is MSForms.TextBox) Or (TypeOf lTextBox Is MSForms.ComboBox) Then
Sheets(lSheet).Range(lTextBox.Tag & lUltimaLinha).Value = lTextBox.Text
Else
If TypeOf lTextBox Is MSForms.OptionButton Then
If lTextBox.Value = True Then
Sheets(lSheet).Range(lTextBox.Tag & lUltimaLinha).Value = lTextBox.Caption
End If
End If
End If
End Sub
Public Function lsInserirTextBox(formulario As UserForm, ByVal lSheet As String, ByVal lColunaCodigo As Long)
Dim controle As Control
Dim lUltimaLinhaAtiva As Long
lUltimaLinhaAtiva = Worksheets(lSheet).Cells(Worksheets(lSheet).Rows.Count, lColunaCodigo).End(xlUp).Row + 1
For Each controle In formulario.Controls
lsInserir controle, lSheet, lColunaCodigo, lUltimaLinhaAtiva
Next
End Function
Public Function lsLimparTextBox(formulario As UserForm)
Dim controle As Control
For Each controle In formulario.Controls
If TypeOf controle Is MSForms.TextBox Then
controle.Text = ""
End If
Next
End Function
Private Sub CommandButton2_Click()
lsLimparTextBox frmCadastro
TextBox1.SetFocus
End Sub
Private Sub Frame1_Click()
End Sub
Private Sub Label1_Click()
End Sub
Private Sub Label3_Click()
End Sub
Private Sub Label4_Click()
End Sub
Private Sub OptionButton2_Click()
End Sub
Private Sub TextBox2_Change()
End Sub
Private Sub TextBox3_Change()
End Sub
Private Sub TextBox4_Change()
End Sub