ผมลงใช้วิธีนี้ครับ ทำการคนหาเฉพาะ Part_no
ลบ ค้าออกจากการนำเข้า Textbox2 ค้าที่เกิน เก็บไว้ใน textbox3 แต่จะติดลบ ตัด - ออก
นำไป ลบ คอลัมถัดไป โดยการกำหนดเงือนไข พอได้มัยครับ
และนานๆไปจะเป็นปัญหา อะไรมัยครับ
Code: Select all
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Try
If Not String.IsNullOrEmpty(TextBox1.Text) Then
Dim keyword As String = Me.TextBox1.Text.Trim()
Me.Table1BindingSource.Filter ="(fff LIKE '%" & keyword & "%')" & ""
'Me.Table1DataGridView.RefreshReport()
Else
Me.Table2BindingSource.RemoveFilter()
End If
Catch ex As Exception
End Try
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Try
For k As Integer = 0 To Table1DataGridView.RowCount - 1
If Convert.ToInt32(Table1DataGridView(3, k).Value) > 0 Then
Dim a As Integer
a = TextBox2.Text
Table1DataGridView(3, k).Value = Table1DataGridView(3, k).Value - a
TextBox2.Clear()
If Convert.ToInt32(Table1DataGridView(3, k).Value < 0) Then
TextBox3.Text = Table1DataGridView(3, k).Value
Table1DataGridView(3, k).Value = 0
End If
If Convert.ToInt32(TextBox3.Text) < 0 Then
Dim b() As String = TextBox3.Text.Split("-")
TextBox3.Text = (b(1))
End If
Exit For
ElseIf Convert.ToInt32(Table1DataGridView(3, k).Value) < 0 Then
TextBox3.Text = Table1DataGridView(3, k).Value
End If
Next
Catch ex As Exception
End Try
Try
For k As Integer = 0 To Table1DataGridView.RowCount - 1
If Convert.ToInt32(TextBox3.Text) > 0 And Table1DataGridView(3, k).Value > 0 Then
Dim a As Integer
a = TextBox3.Text
Table1DataGridView(3, k).Value = Table1DataGridView(3, k).Value - a
TextBox3.Clear()
Exit For
End If
Next
Catch ex As Exception
End Try