Patriot2879
Well-known Member
- Joined
- Feb 1, 2018
- Messages
- 1,227
- Office Version
- 2010
- Platform
- Windows
hi my listbox data from the textbox1 the date is in american format how do i force it to show dd/mm/yy? the code below is for my textbox1 and the code below that is for my listbox1 hope you can help please?
VBA Code:
Private Sub TextBox1_Change()
Dim ascii As Integer
Dim d As Integer
Dim m As Integer
Dim n As Integer
n = Len(TextBox1.Value)
If n = 0 Then Exit Sub
ascii = Asc(Right(TextBox1.Value, 1))
' Validate the day is 2 digits from 01 to 31.
If n = 2 And ascii <> 47 And CharCode <> 8 Then
d = CInt(Left(TextBox1.Value, 2))
If d < 1 Or d > 31 Then
MsgBox "Invalid day number " & d & vbLf & "Days are from 01 to 31."
TextBox1.Value = ""
Exit Sub
End If
End If
' Validate the month is 2 digits from 01 to 12.
If n = 5 And ascii <> 47 And CharCode <> 8 Then
m = CInt(Mid(TextBox1.Value, 4, 2))
If m < 1 Or m > 12 Then
MsgBox "Invalid month number " & m & vbLf & "Months are from 01 to 12."
TextBox1.Value = Left(TextBox1.Value, 3)
End If
End If
End Sub
Code:
Private Sub ListBox1_AfterUpdate()
ListBox2.ListIndex = ListBox1.ListIndex
Me.TextBox1.Value = Me.ListBox1.Column(0)
Me.TextBox2.Value = Me.ListBox1.Column(1)
Me.TextBox3.Value = Me.ListBox1.Column(2)
Me.TextBox4.Value = Me.ListBox1.Column(3)
Me.TextBox5.Value = Me.ListBox1.Column(4)
Me.TextBox6.Value = Me.ListBox1.Column(5)
Me.TextBox7.Value = Me.ListBox1.Column(6)
Me.TextBox10.Value = Me.ListBox2.Column(0)
Me.TextBox11.Value = Me.ListBox2.Column(1)
Me.TextBox12.Value = Me.ListBox2.Column(2)
Me.TextBox13.Value = Me.ListBox2.Column(3)
Me.TextBox14.Value = Me.ListBox2.Column(4)
Me.TextBox15.Value = Me.ListBox2.Column(5)
Me.TextBox16.Value = Me.ListBox2.Column(6)
Me.TextBox17.Value = Me.ListBox2.Column(7)
Me.TextBox18.Value = Me.ListBox2.Column(8)
Me.TextBox19.Value = Me.ListBox2.Column(9)
End Sub