Olá pessoal, aprendendo ainda o vba, tenho um form com um listbox desacoplada e com a propriedade exiberCabeçalho 'sim', porém com eu clico na primeira linha da listabox carrega no formulário os dados do cabeçalho da listabox. como corrigir esse erro?
abaixo meu código:
Private Sub lstFrete_Click()
With Me.lstFrete
Dim selectedIndex As Long
selectedIndex = .ListIndex
Me.cbxFrete.Value = .Column(0, selectedIndex)
Me.txtNViagem.Value = .Column(1, selectedIndex)
Me.cbxFrete.Value = .Column(0, selectedIndex)
Me.txtNViagem.Value = .Column(1, selectedIndex)
Me.txtcpnj.Value = .Column(3, selectedIndex)
Me.txtNomeCliente.Value = .Column(4, selectedIndex)
Me.txtcelCliente.Value = .Column(6, selectedIndex)
Me.txtData.Value = .Column(7, selectedIndex)
Me.txtDtInicViag.Value = .Column(8, selectedIndex)
Me.txtDtFimViag.Value = .Column(9, selectedIndex)
Me.cboPreco.Value = .Column(10, selectedIndex)
Me.txtFrNeg.Value = .Column(12, selectedIndex)
Me.cboTipoVeic.Value = .Column(13, selectedIndex)
Me.txtQtdeVolu.Value = .Column(14, selectedIndex)
Me.txtCubagem.Value = .Column(15, selectedIndex)
Me.txtPeso.Value = .Column(16, selectedIndex)
Me.txtKmSaida.Value = .Column(17, selectedIndex)
Me.txtKmChega = .Column(18, selectedIndex)
Me.txtVrKm.Value = .Column(19, selectedIndex)
Me.txtFrtPeso.Value = .Column(20, selectedIndex)
Me.cboPlViagem.Value = .Column(22, selectedIndex)
Me.cboIdColab.Value = .Column(24, selectedIndex)
Me.txtNomeProprietario.Value = .Column(24, selectedIndex)
Me.txtCelMotor.Value = .Column(25, selectedIndex)
Me.StatusVeículo = (.Column(26, selectedIndex) = 0)
Me.txtFrCubagem.Value = .Column(27, selectedIndex)
End With
End Sub
Desde agradeço pela ajuda.
abaixo meu código:
Private Sub lstFrete_Click()
With Me.lstFrete
Dim selectedIndex As Long
selectedIndex = .ListIndex
Me.cbxFrete.Value = .Column(0, selectedIndex)
Me.txtNViagem.Value = .Column(1, selectedIndex)
Me.cbxFrete.Value = .Column(0, selectedIndex)
Me.txtNViagem.Value = .Column(1, selectedIndex)
Me.txtcpnj.Value = .Column(3, selectedIndex)
Me.txtNomeCliente.Value = .Column(4, selectedIndex)
Me.txtcelCliente.Value = .Column(6, selectedIndex)
Me.txtData.Value = .Column(7, selectedIndex)
Me.txtDtInicViag.Value = .Column(8, selectedIndex)
Me.txtDtFimViag.Value = .Column(9, selectedIndex)
Me.cboPreco.Value = .Column(10, selectedIndex)
Me.txtFrNeg.Value = .Column(12, selectedIndex)
Me.cboTipoVeic.Value = .Column(13, selectedIndex)
Me.txtQtdeVolu.Value = .Column(14, selectedIndex)
Me.txtCubagem.Value = .Column(15, selectedIndex)
Me.txtPeso.Value = .Column(16, selectedIndex)
Me.txtKmSaida.Value = .Column(17, selectedIndex)
Me.txtKmChega = .Column(18, selectedIndex)
Me.txtVrKm.Value = .Column(19, selectedIndex)
Me.txtFrtPeso.Value = .Column(20, selectedIndex)
Me.cboPlViagem.Value = .Column(22, selectedIndex)
Me.cboIdColab.Value = .Column(24, selectedIndex)
Me.txtNomeProprietario.Value = .Column(24, selectedIndex)
Me.txtCelMotor.Value = .Column(25, selectedIndex)
Me.StatusVeículo = (.Column(26, selectedIndex) = 0)
Me.txtFrCubagem.Value = .Column(27, selectedIndex)
End With
End Sub
Desde agradeço pela ajuda.