By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,984 Members | 2,794 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,984 IT Pros & Developers. It's quick & easy.

Weird behaviour with If statement and array code

P: n/a
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(Ins RoomBooking

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

'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(Mea lInsRow
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.
Jul 21 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Cor
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
Jul 21 '05 #2

P: n/a
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
Jul 21 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.