473,474 Members | 1,602 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Weird behaviour with If statement and array code

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
2 1117
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Jon Combe | last post by:
I have created the following test SQL code to illustrate a real problem I have with some SQL code. CREATE TABLE JCTable ( CustomerName varchar(50) ) ALTER TABLE JCTable ADD CustomerNo int...
1
by: Keiron Waites | last post by:
Ok to understand what I'm doing you'll have to load the HTML file attached (code also below): When you select an item on the left and select the ">>" button, some alerts will come up telling you...
8
by: Deano | last post by:
Here's the code; Private Sub txtTeachName_LostFocus() If IsNull(Me.txtName) Then 'line A Forms!frmMainform!frmSubform.Locked = True GoTo Exit_txtName Else 'line B...
3
by: Val | last post by:
In vc7 (studio 2002), when I try to debug the first "if" statement, the IDE jumps to the next valid line and evaluates it even if the if-statement is false. What is going on? if(...
2
by: Bhavna | last post by:
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...
12
by: Mick_fae_Glesga | last post by:
OK, the solution to this is probably blindingly obvious to everyone, but... surely it can't be right. I am compiling with borland bcc32 free compiler this piece of code is designed to identify...
19
by: Sharath A.V | last post by:
I had an argument with someone on wheather this piece of code can invoke undefined bahaviour. I think it does not invoke any undefined behaviour since there is sufficient memory space of 9...
0
by: P Pulkkinen | last post by:
Dear all, sorry, i know this code is far little too long to debug here, but there is really annoying logical error. If someone debugs this, I really offer warm virtual handshake. What this...
285
by: Sheth Raxit | last post by:
Machine 1 : bash-3.00$ uname -a SunOS <hostname5.10 Generic_118822-30 sun4u sparc SUNW,Sun-Fire-280R bash-3.00$ gcc -v Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.8/2.95.3/...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.