Page 1 of 1

ลบข้อมูลใน TextBox1.2.3

Posted: Wed Jan 02, 2019 7:26 pm
by วังวู ช่ง
อยากเรียนถามว่า
เมื่อเรากด เพี่มข้อมูล
แล้วข้อมูลใน TextBox1, TextBox2 และ TextBox3 หายไปแบบ auto ต้องปลับ code ตรงไหนครับ

Code: Select all

Private Sub CommandButton1_Click()
emptyRow = WorksheetFunction.CountA(Range("B:B")) + 1

Cells(emptyRow, 1).Value = TextBox1.Value
Cells(emptyRow, 2).Value = TextBox2.Value
Cells(emptyRow, 3).Value = TextBox3.Value
End Sub
Private Sub CommandButton2_click()
Unload Me
End Sub
Private Sub UserForm_Initialize()
TextBox1.Value = ""
TextBox2.Value = ""
TextBox3.Value = ""
End Sub

Re: ลบข้อมูลใน TextBox1.2.3

Posted: Wed Jan 02, 2019 8:15 pm
by snasui
:D ตัวอย่าง Code ครับ

Code: Select all

Private Sub CommandButton1_Click()
    emptyRow = WorksheetFunction.CountA(Range("B:B")) + 1
    
    Cells(emptyRow, 1).Value = TextBox1.Value
    Cells(emptyRow, 2).Value = TextBox2.Value
    Cells(emptyRow, 3).Value = TextBox3.Value
    
    TextBox1.Value = ""
    TextBox2.Value = ""
    TextBox3.Value = ""
End Sub

Re: ลบข้อมูลใน TextBox1.2.3

Posted: Wed Jan 02, 2019 8:22 pm
by วังวู ช่ง
snasui wrote: Wed Jan 02, 2019 8:15 pm :D ตัวอย่าง Code ครับ

Code: Select all

Private Sub CommandButton1_Click()
    emptyRow = WorksheetFunction.CountA(Range("B:B")) + 1
    
    Cells(emptyRow, 1).Value = TextBox1.Value
    Cells(emptyRow, 2).Value = TextBox2.Value
    Cells(emptyRow, 3).Value = TextBox3.Value
    
    TextBox1.Value = ""
    TextBox2.Value = ""
    TextBox3.Value = ""
End Sub
:D :D :D :thup: :thup: :thup: :cp: :cp: :cp:

Re: ลบข้อมูลใน TextBox1.2.3

Posted: Wed Jan 02, 2019 8:23 pm
by วังวู ช่ง
ได้ตามต้องการเลยครับ ขอบคุณมากครับอาจารย์