I have a datagridview and i basically click a button that goes through all the rows in the table looking at two particular columns: quantity and re-order level.
After every row the code checks to see If the re-order level is greater than the quantity of that particular row.

if the re-order level if greater than the quantity a messagebox appears MsgBox("Need to re-order" & name)

if the re-order level is not greater than the quantity a message box appears MsgBox("Stock is OK")

i am not sure how to go about writing up code so that a message box appears at the very end of the loop displaying all the names of the items that need re-ordering

so it would be along the lines of a msgbox showing the following after the loop is complete

Need to re order the following items:
'list of all the names that need re-ordering

if anyone knows any links that would be useful or any help or advice will be greatly appreciated as am pretty new to this


Private Sub btnCheckStockStatus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCheckStockStatus.Click

Dim increment As Integer = 0
Dim quantity, reorderlevel As Integer
Dim name As String

MaxRows = KiwicyclesDataSet.Stock_Control.Rows.Count

For increment = 0 To MaxRows - 1

quantity = KiwicyclesDataSet.Stock_Control.Rows(increment).Item("Quantity")
reorderlevel = KiwicyclesDataSet.Stock_Control.Rows(increment).Item("Re-Order Level")
name = KiwicyclesDataSet.Stock_Control.Rows(increment).Item("Model")

If reorderlevel >= quantity Then
MsgBox("Need to re-order" & name)
Else
MsgBox("Stock is OK")
End If

Next

End Sub

Hi
You would need to hold your values in a string or some other variable that you can then put into a message box at the end of your loop. e.g.

dim ReOrderItems as String

For increment = 0 To MaxRows - 1

quantity = KiwicyclesDataSet.Stock_Control.Rows(increment).Item("Quantity")
reorderlevel = KiwicyclesDataSet.Stock_Control.Rows(increment).Item("Re-Order Level")
name = KiwicyclesDataSet.Stock_Control.Rows(increment).Item("Model")

If reorderlevel >= quantity Then
MsgBox("Need to re-order" & name)
ReOrderItems = ReOrderItems &name &", "
Else
MsgBox("Stock is OK")
End If

Next
msgbox("The following items need to be restocked:" &vbcrlf  &ReOrderItems)

Hi
You would need to hold your values in a string or some other variable that you can then put into a message box at the end of your loop. e.g.

dim ReOrderItems as String

For increment = 0 To MaxRows - 1

quantity = KiwicyclesDataSet.Stock_Control.Rows(increment).Item("Quantity")
reorderlevel = KiwicyclesDataSet.Stock_Control.Rows(increment).Item("Re-Order Level")
name = KiwicyclesDataSet.Stock_Control.Rows(increment).Item("Model")

If reorderlevel >= quantity Then
MsgBox("Need to re-order" & name)
ReOrderItems = ReOrderItems &name &", "
Else
MsgBox("Stock is OK")
End If

Next
msgbox("The following items need to be restocked:" &vbcrlf  &ReOrderItems)

thanks!

hi am new here and in vb.net
and i've been trying to display outputs form an array but the message box appears empty with nothing in it ..
here is the code :

Dim r As Random = New Random()

For i = 1 To dept_no


For j = 0 To dept(i).GetUpperBound(0) - 1

dept(i)(j) = r.Next(300, 1000)
output &= dept(i)(j) & " "


Next
output &= vbCrLf


Next
MessageBox.Show("salaries are" & vbTab & output)

hi am new here and in vb.net
and i've been trying to display outputs form an array but the message box appears empty with nothing in it ..
here is the code :

Dim r As Random = New Random()

For i = 1 To dept_no


For j = 0 To dept(i).GetUpperBound(0) - 1

dept(i)(j) = r.Next(300, 1000)
output &= dept(i)(j) & " "


Next
output &= vbCrLf


Next
MessageBox.Show("salaries are" & vbTab & output)

Hi

Where are you defining the size of your Array?

Also parse through your code in debugg mode and add a watch to the output string does the value change with each loop and is it increasing?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.