dneprcomp Вот код:
Private Sub FindBut_Click()
Dim strItemCode As String
Dim lngCurRowIndex As String
Dim bolFound As Boolean
Dim objMsgBoxResult As VbMsgBoxResult
Dim strActualQuantity As String
Dim strFullQuantity As String
Dim strCurQuantity As String
Dim lngRowFound As Long
Dim strCurNumOfRolls As String
Dim lngDifference As Long
Dim strProductName As String
Dim strUserName As String
strItemCode = _
InputBox( _
"Please insert the item code", _
"Insert code")
If (Len(strItemCode) = 0) Then
Exit Sub
End If
strItemCode = UCase(strItemCode) '*****
lngCurRowIndex = c_lngDataFirstRowIndex
bolFound = False
Do While Len(GettingKit.Spreadsheet1.Cells(lngCurRowIndex, 1)) > 0
If (strItemCode = GettingKit.Spreadsheet1.Cells(lngCurRowIndex, 1)) Then
bolFound = True
lngRowFound = lngCurRowIndex
End If
lngCurRowIndex = lngCurRowIndex + 1
Loop
If (bolFound = True) Then
If (GettingKit.Spreadsheet1.Cells(lngRowFound, 5) = "OK") Then
objMsgBoxResult = _
MsgBox( _
"The quantity is enough. are you sure you want to add?", _
vbYesNo + vbQuestion, _
"Confirmation")
If (objMsgBoxResult = vbNo) Then
Exit Sub
End If
End If
strActualQuantity = _
InputBox( _
"Please insert the actual quantity of " & strItemCode, _
"Insert Actual Quantity")
If (Len(strActualQuantity) = 0) Then
Exit Sub
End If
strCurQuantity = GettingKit.Spreadsheet1.Cells(lngRowFound, 3).Select
GettingKit.Spreadsheet1.Cells(lngRowFound, 3).Font.Color = vbGreen
If (Len(strCurQuantity) = 0) Then
GettingKit.Spreadsheet1.Cells(lngRowFound, 3) = strActualQuantity
Else
GettingKit.Spreadsheet1.Cells(lngRowFound, 3) = CLng(GettingKit.Spreadsheet1.Cells(lngRowFound, 3)) + CLng(strActualQuantity)
End If
strCurNumOfRolls = GettingKit.Spreadsheet1.Cells(lngRowFound, 4)
If (Len(strCurNumOfRolls) = 0) Then
GettingKit.Spreadsheet1.Cells(lngRowFound, 4) = 1
Else
GettingKit.Spreadsheet1.Cells(lngRowFound, 4) = CLng(GettingKit.Spreadsheet1.Cells(lngRowFound, 4)) + 1
End If
Else
lngRowFound = lngCurRowIndex
objMsgBoxResult = _
MsgBox( _
strItemCode & " doesn't exists. Would you like to add it?", _
vbYesNo + vbQuestion, _
"Item doesn't exists")
If (objMsgBoxResult = vbYes) Then
strFullQuantity = _
InputBox( _
"Please insert the full qunatity of " & strItemCode, _
"Insert Full Quantity")
objMsgBoxResult = _
MsgBox( _
"Are you sure you want to insert item '" & strItemCode & "' with full quantity " & strFullQuantity & "?", _
vbYesNo + vbQuestion, _
"Confirmation")
If (objMsgBoxResult = vbYes) Then
strActualQuantity = _
InputBox( _
"Please insert the actual qunatity of " & strItemCode, _
"Insert Actual Quantity")
If (Len(strActualQuantity) = 0) Then
Exit Sub
End If
GettingKit.Spreadsheet1.Cells(lngRowFound, 1) = strItemCode
GettingKit.Spreadsheet1.Cells(lngRowFound, 2) = strFullQuantity
GettingKit.Spreadsheet1.Cells(lngRowFound, 3) = strActualQuantity
GettingKit.Spreadsheet1.Cells(lngRowFound, 4) = 1
End If
End If
End If
If (Len(GettingKit.Spreadsheet1.Cells(lngRowFound, 3)) > 0) Then
lngDifference = CLng(GettingKit.Spreadsheet1.Cells(lngRowFound, 3)) - CLng(GettingKit.Spreadsheet1.Cells(lngRowFound, 2))
GettingKit.Spreadsheet1.Cells(lngRowFound, 5) = CStr(lngDifference)
End If
End Sub
Добавлено: и заранее огромное спасибо
)