Harin
Harin

Reputation: 57

Date does not come up in textboxes from Listbox

I wonder if anyone could help me, I have a listbox of data and when you double click on the line in listbox then all of the text boxes populate with the data from the listbox including 2 different textboxes which contains dates however it does not show the date as DD/MM/YYYY instead it shows numbers.

can someone please help me.

below it is the code.

Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean)

If IsNull(Me.ListBox1.Value) Then
MsgBox "Please double click on the name line", vbExclamation, "Select a Name Line"
Else

    If Me.ListBox1.List(Me.ListBox1.ListIndex, 0) <> "" Then
    
    Me.CommandButton1.Enabled = False
     Me.CommandButton2.Enabled = True
   
    Me.TextBox1.Value = Me.ListBox1.List(Me.ListBox1.ListIndex, 1)
    Me.TextBox1.Enabled = False
    Me.TextBox1.BackColor = RGB(155, 295, 155)
    
        Me.TextBox2.Value = Me.ListBox1.List(Me.ListBox1.ListIndex, 2)
        Me.TextBox2.Enabled = False
        Me.TextBox2.BackColor = RGB(155, 295, 155)
    
    Me.TextBox3.Value = Me.ListBox1.List(Me.ListBox1.ListIndex, 3)
    Me.TextBox3.Enabled = False
    Me.TextBox3.BackColor = RGB(155, 295, 155)
   
    
    Me.TextBox5.Value = Me.ListBox1.List(Me.ListBox1.ListIndex, 4)
  
    
    Me.TextBox6.Value = Me.ListBox1.List(Me.ListBox1.ListIndex, 5)
    Me.TextBox7.Value = Me.ListBox1.List(Me.ListBox1.ListIndex, 6)
      
    Me.TextBox8.Value = Me.ListBox1.List(Me.ListBox1.ListIndex, 7)
    Me.ComboBox1.Value = Me.ListBox1.List(Me.ListBox1.ListIndex, 8)
  
    
    Me.TextBox9.Value = Me.ListBox1.List(Me.ListBox1.ListIndex, 9)
        
        ' Textbox10 it is the Date box
        Me.TextBox10.Value = Me.ListBox1.List(Me.ListBox1.ListIndex, 10)
        
        Me.TextBox37.Value = Me.ListBox1.List(Me.ListBox1.ListIndex, 11)
        Me.TextBox38.Value = Me.ListBox1.List(Me.ListBox1.ListIndex, 12)
        Me.TextBox39.Value = Me.ListBox1.List(Me.ListBox1.ListIndex, 15)
        
        ' Textbox11 it is the Date box
            Me.TextBox11.Value = Me.ListBox1.List(Me.ListBox1.ListIndex, 13)
            Me.TextBox12.Value = Me.ListBox1.List(Me.ListBox1.ListIndex, 14)
                    
    Me.TextBox13.Value = Me.ListBox1.List(Me.ListBox1.ListIndex, 16)
     Me.TextBox13.Enabled = False
    Me.TextBox13.BackColor = RGB(155, 295, 155)
                    
End If

End If


End Sub

Upvotes: 0

Views: 516

Answers (1)

Tim Williams
Tim Williams

Reputation: 166381

For example:

Me.TextBox10.Value = Format(Me.ListBox1.List(Me.ListBox1.ListIndex, 10), "DD/MM/YYYY")

Upvotes: 1

Related Questions