Page 1 of 1

นำค่าใน Listbox to textbox

Posted: Mon Jun 08, 2020 4:49 pm
by yodpao.b
นำค่าใน Listbox to textbox
0.JPG
จากรูป อยากให้ขึ้นเฉพาะตัวเลข 84 ครับ

Code: Select all

Private Sub ListBox1_Click()



Me.[txtIDStart11] = Me.ListBox1.Column(0)


End Sub

Re: นำค่าใน Listbox to textbox

Posted: Mon Jun 08, 2020 6:26 pm
by Totem
:D เพิ่ม code ในช่อง text ที่ชื่อ txtIDStart11

Code: Select all

Private Sub txtIDStart11_Change()
Dim i As Long
Dim Lines() As String
Dim Values() As String
Lines() = Split(ListBox1.Column(0), vbCrLf)
For i = 0 To UBound(Lines)
    If Lines(i) > vbNullString Then
        Values() = Split(Lines(i), ".")
        Me.[txtIDStart11] = Values(0)
    End If
Next i
End Sub
ใช่หรือเปล่าครับ

Re: นำค่าใน Listbox to textbox

Posted: Mon Jun 08, 2020 7:45 pm
by yodpao.b
ขอบคุณครับ
ดูแล้ว ไม่เข้าใจ แต่พอเห็น Split ก็เข้าใจ พอสมควร
ขอบคุณครับ จะได้ทำต่อเสียที่