+ Reply to Thread
Results 1 to 2 of 2

entrada de dados

  1. #1
    Registered User
    Join Date
    07-12-2015
    Location
    Hortolândia
    MS-Off Ver
    2010
    Posts
    1

    entrada de dados

    Boa noite amigos sou novo no fórum, estou acompanhando umas video aulas fiz o form de cadastro com sucesso mas o de entrada quando clico no botão novo da erro em tempo de execução '13'; tipos incompatíveis o erro
    da na textbox5 no cod = textbox3

    Private Sub CommandButton1_Click()

    If TextBox2 = "" Or TextBox3 = "" Or TextBox4 = "" Or TextBox5 = "" Then
    MsgBox "EXISTEM CAMPOS A SEREM DIGITADOS", vbCritical, "ATENÇÃO"
    Else


    Dim DATA As Date
    Dim Valor As Single
    DATA = TextBox2
    Valor = TextBox6

    If L1 = "NOVO" Then
    MSG = MsgBox("CONFIRMA A ENTRADA DO PRODUTO?", vbOKCancel, "ATENÇÃO")
    If MSG = 1 Then

    A = Application.WorksheetFunction.CountA(Plan3.Columns(1)) + 1
    Plan3.Cells(A, 1) = TextBox1.Text
    Plan3.Cells(A, 2) = DATA
    Plan3.Cells(A, 3) = TextBox3
    Plan3.Cells(A, 4) = TextBox4
    Plan3.Cells(A, 5) = TextBox5.Text
    Plan3.Cells(A, 6) = Valor
    CommandButton2_Click
    MsgBox "ENTRADA REALIZADA COM SUCESSO!!!", vbInformation, "SERVCAMP"

    Else
    End If
    Else

    If L1 = "ALTERAR" Then
    MS = MsgBox("CONFIRMA A ALTERAÇÃO DO PRODUTO?", vbOKCancel, "ATENÇÃO")
    If MS = 1 Then

    Dim CORR As Single
    CORR = TextBox1
    B = Application.WorksheetFunction.Match(CORR, Plan3.Columns(1), 0)
    Plan3.Cells(B, 2) = DATA
    Plan3.Cells(B, 3) = TextBox3
    Plan3.Cells(B, 4) = TextBox4
    Plan3.Cells(B, 5) = TextBox5.Text
    Plan3.Cells(B, 6) = Valor
    CommandButton2_Click
    Else
    End If
    End If
    End If
    End If


    End Sub

    Private Sub CommandButton2_Click()
    TextBox1 = ""
    TextBox2 = ""
    TextBox3 = ""
    TextBox4 = ""
    TextBox5 = ""
    TextBox6 = ""
    TextBox1.Enabled = False
    TextBox2.Enabled = False
    TextBox3.Enabled = False
    TextBox4.Enabled = False
    TextBox5.Enabled = False
    TextBox6.Enabled = False

    CommandButton3.Enabled = True
    CommandButton4.Enabled = True
    CommandButton5.Enabled = True
    CommandButton6.Enabled = True
    CommandButton1.Enabled = False
    CommandButton2.Enabled = False



    End Sub

    Private Sub CommandButton3_Click()
    L1 = "NOVO"
    TextBox1 = WorksheetFunction.Max(Plan3.Columns(1)) + 1
    TextBox2.Enabled = True
    TextBox3.Enabled = True
    TextBox4.Enabled = True
    TextBox5.Enabled = True
    TextBox6.Enabled = True

    TextBox2 = Date
    TextBox3 = ""
    TextBox4 = ""
    TextBox5 = ""
    TextBox6 = ""
    CommandButton3.Enabled = False
    CommandButton4.Enabled = False
    CommandButton5.Enabled = False
    CommandButton6.Enabled = False
    CommandButton1.Enabled = True
    CommandButton2.Enabled = True
    End Sub

    Private Sub CommandButton4_Click()
    L1 = "ALTERAR"
    TextBox1.Enabled = True
    CommandButton3.Enabled = False
    CommandButton4.Enabled = False
    CommandButton5.Enabled = False
    CommandButton6.Enabled = False
    CommandButton1.Enabled = True
    CommandButton2.Enabled = True

    End Sub

    Private Sub CommandButton5_Click()
    L1 = "CONSULTAR"
    TextBox1.Enabled = True
    CommandButton3.Enabled = False
    CommandButton4.Enabled = False
    CommandButton5.Enabled = False
    CommandButton6.Enabled = False
    CommandButton1.Enabled = True
    CommandButton2.Enabled = True
    End Sub

    Private Sub CommandButton6_Click()
    L1 = "EXCLUIR"
    TextBox1.Enabled = True
    CommandButton3.Enabled = False
    CommandButton4.Enabled = False
    CommandButton5.Enabled = False
    CommandButton6.Enabled = False
    CommandButton1.Enabled = True
    CommandButton2.Enabled = True
    End Sub





    Private Sub Label1_Click()

    End Sub

    Private Sub Label6_Click()

    End Sub

    Private Sub TEXTBOX1_Change()

    End Sub

    Private Sub TEXTBOX1_(ByVal Cancel As MSForms.ReturnBoolean)
    On Error GoTo trata

    Dim cod As Single
    cod = TextBox1
    TextBox2 = Application.WorksheetFunction.VLookup(cod, Plan3.Range("a:z"), 2, 0)
    TextBox3 = Application.WorksheetFunction.VLookup(cod, Plan3.Range("a:z"), 3, 0)
    TextBox4 = Application.WorksheetFunction.VLookup(cod, Plan3.Range("a:z"), 4, 0)
    TextBox5 = Application.WorksheetFunction.VLookup(cod, Plan3.Range("a:z"), 5, 0)
    TextBox6 = Application.WorksheetFunction.VLookup(cod, Plan3.Range("a:z"), 6, 0)
    TextBox6 = Format(TextBox6, "R$ #,##0.00")
    TextBox2 = Format(TextBox2, "dd/mm/yyyy")
    If L1 = "CONSULTAR" Then
    TextBox1.Enabled = False
    Else
    If L1 = "ALTERAR" Then
    TextBox1.Enabled = False
    TextBox2.Enabled = True
    TextBox3.Enabled = True
    TextBox4.Enabled = True
    TextBox5.Enabled = True
    TextBox6.Enabled = True
    Else
    If L1 = "EXCLUIR" Then
    MSG = MsgBox("CONFIRMA A EXCLUSÃO DO PRODUTO?", vbOKCancel, "ATENÇÃO")
    If MSG = 1 Then
    Dim CORR As Single
    CORR = TextBox1
    B = Application.WorksheetFunction.Match(CORR, Plan3.Columns(1), 0)
    Plan3.Rows(2).Delete Shift:=xlUp
    Plan3.Rows(B).Delete Shift:=xlUp
    CommandButton2_Click
    Else

    End If
    End If
    End If
    End If
    'Sub
    trata:
    MsgBox "Produto não Cadastrado", vbInformation, "ServCamp"


    End Sub

    Private Sub TEXTBOX4_Change()

    End Sub

    Private Sub TEXTBOX4_(ByVal Cancel As MSForms.ReturnBoolean)
    TextBox4 = Format(TextBox4, "R$ #,##0.00")




    End Sub

    Private Sub TextBox5_Exit(ByVal Cancel As MSForms.ReturnBoolean)


    Dim cod As Single
    cod = TextBox3
    TextBox6 = Application.WorksheetFunction.VLookup(cod, Plan2.Range("A:Z"), 4, 0) * TextBox5



    End Sub

    Private Sub TextBox6_Change()

    End Sub

    Private Sub UserForm_Click()

    End Sub

    Private Sub UserForm_Initialize()


    End Sub

  2. #2
    Registered User
    Join Date
    08-23-2015
    Location
    Spain
    MS-Off Ver
    2007
    Posts
    32

    Re: entrada de dados

    Hola, estás asignando el valor de TextBox3 directamente a una variable tipo single... el error puede deberse a:

    1) TextBox3 está vacío [value = ""]
    2) TextBox3 es un texto no numérico [not numeric string]

    Solución:
    Please Login or Register  to view this content.
    May the REPUTATION be with me

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Controle de Saída e Entrada de Veiculos
    By anacleto8000 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-08-2013, 09:53 AM
  2. Controle de Saída e Entrada de Veiculos
    By anacleto8000 in forum Non English Excel
    Replies: 0
    Last Post: 10-08-2013, 06:43 AM
  3. Controle de Saída e Entrada de Veiculos
    By anacleto8000 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-08-2013, 06:43 AM
  4. Unindo dados entre varias planilhas (Microsoft Query) Excel 2010
    By anacleto8000 in forum Non English Excel
    Replies: 0
    Last Post: 10-08-2013, 06:40 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1