Excel 日期不会出现在Listbox的文本框中

Excel 日期不会出现在Listbox的文本框中,excel,vba,Excel,Vba,我想知道是否有人可以帮助我,我有一个数据列表框,当你双击列表框中的行时,所有文本框都会填充列表框中的数据,包括两个不同的文本框,其中包含日期,但它不显示日期为DD/MM/YYYY,而是显示数字 谁能帮帮我吗 下面是代码 Private Sub ListBox1_DblClick(ByVal Cancel As MSForms.ReturnBoolean) If IsNull(Me.ListBox1.Value) Then MsgBox "Please double click on

我想知道是否有人可以帮助我,我有一个数据列表框,当你双击列表框中的行时,所有文本框都会填充列表框中的数据,包括两个不同的文本框,其中包含日期,但它不显示日期为DD/MM/YYYY,而是显示数字

谁能帮帮我吗

下面是代码

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
Private子列表框1\u DblClick(ByVal Cancel作为MSForms.ReturnBoolean)
如果IsNull(Me.ListBox1.Value),则
MsgBox“请双击名称行”,VBE感叹号,“选择名称行”
其他的
如果Me.ListBox1.List(Me.ListBox1.ListIndex,0)“,则
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(155295155)
Me.TextBox2.Value=Me.ListBox1.List(Me.ListBox1.ListIndex,2)
Me.TextBox2.Enabled=False
Me.TextBox2.BackColor=RGB(155295155)
Me.TextBox3.Value=Me.ListBox1.List(Me.ListBox1.ListIndex,3)
Me.TextBox3.Enabled=False
Me.TextBox3.BackColor=RGB(155295155)
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)
'文本框10它是日期框
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)
'文本框11它是日期框
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(155295155)
如果结束
如果结束
端接头
例如:

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

嗨,蒂姆,非常感谢你的快速回复,这解决了我的问题。再次感谢你。