Weird behaviour with If statement and array code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

hello

Can anyone help me with a problem i have
I have made an array to hold values. I am adding values to this array when the user clicks an 'Add' butto

If Not ((CBoxMealName.Text = "") Or (txtMealQty.Text = "")) The

Dim ChosenMeal As Strin
ChosenMeal = CBoxMealName.Text.ToStrin
Dim Quantity As Intege
Quantity = txtMealQty.Tex

MyMealTypeArray(ArrayIndex) = ChosenMea
MyMealQtyArray(ArrayIndex) = Quantit

ArrayIndex = (ArrayIndex + 1
Els
MsgBox("Please ensure all the required fields are entered correctly"
End I

When the user selects the submit button, i want these values pushed to a Meal Booking datatable
Here is the submit button code

Dim InsRoomBooking As DataRo
Dim MealInsRow As DataRo

If Not ((CBoxRoomNames.Text = "") Or (CBoxLayout.Text = "") Or (txtNoOfGuests.Text
= "") Or (CBoxSession.Text = "")) The

Dim RoomIDB4Substr As String = CBoxRoomNames.Tex
Dim RoomID As String = RoomIDB4Substr.Substring(0, 3

'PUSH THE DATA INTO MY ROOM BOOKING DATATABL
InsRoomBooking = dsFullBooking.Tables("dtRoomBooking").NewRow(
InsRoomBooking("BookingNo") = "-1
InsRoomBooking("RoomID") = RoomI
InsRoomBooking("RoomDt") = dtpRoomDate.Value.ToShortDateStrin
InsRoomBooking("Room_Name") = CBoxRoomNames.Tex
InsRoomBooking("Req_Session") = CBoxSession.Tex
InsRoomBooking("Req_Layout") = CBoxLayout.Tex
InsRoomBooking("No_Of_Guests") = txtNoOfGuests.Tex
InsRoomBooking("Room_Cost") = lblRoomCharge.Tex

dsFullBooking.Tables("dtRoomBooking").Rows.Add(InsRoomBooking

'----------------------------------------------------------------------

'PUSH THE MEAL BOOKING DATA FROM MY ARRAY INTO THE MEAL BOOKING DATATABL
For ArrayIndex = 0 To (ArrayIndex - 1
MealInsRow = dsFullBooking.Tables("dtMealBooking").NewRow(
MealInsRow("BookingNo") = "-1
MealInsRow("RoomID") = RoomI
MealInsRow("RoomDt") = dtpRoomDate.Tex
MealInsRow("Req_Session") = CBoxSession.Tex
MealInsRow("Meal_Type") = MyMealTypeArray(ArrayIndex
MealInsRow("Meal_Qty") = MyMealQtyArray(ArrayIndex
dsFullBooking.Tables("dtMealBooking").Rows.Add(MealInsRow
Next ArrayInde


Else : MsgBox("Please ensure all the required fields are entered correctly"

End I

The problem is that my Meal booking datatable does not get popualted with the values from my array. My RoomBooking Datatable works fine however!!

When i take the array code out of the IF statement, it works fine!!
Is there something i am missing here!!?

Any help would be appreciated.
 
Yes Bhavna,

If I see it good you make a bitwise Or from it.
If Not ((CBoxMealName.Text = "") Or (txtMealQty.Text = "")) Then

I think you want to say
If xx<>"" OrElse yy<>"" then

I hope this helps

Cor
 
Thanku cor,

I will use the coding u recommended. I solved the problem. It had something to do with the radiobutton_checked event that was firing when i reset the values. I found a small line there that cleared my datatable ;)

Its amazing how a simple mistake can cause so many problems :o)

thx again
 
Back
Top