473,385 Members | 1,344 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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 1116
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/...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

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.