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

Home Posts Topics Members FAQ

if statements...please help :)

18 New Member
Hi! I am using vb.net and have some basic questions


I was wondering if i have a very long line of code (a long if statement), can it extend onto two lines? If so how would I do that?

I also wanted to know say I have 7 checkboxes and the condition on my if statement is to check if only one box has been checked, is the only way to do this by having all the different combinations listed?

Thank you for any help, I am fairly new to vb.net and would appreciate any insight!!!
Nov 2 '07 #1
5 1249
willywonka
18 New Member
Hi..it's me again.

I tried using a loop to get the count of each checkbox that is check but i don't think that i can use checkboxi.checked (where i is the number of the checkbox) do you always have to state the proper name for the checkbox like checkbox1 instead of checkboxi where i=1?

Thanks again for any help!!!
Nov 2 '07 #2
nateraaaa
663 Recognized Expert Contributor
Hi! I am using vb.net and have some basic questions


I was wondering if i have a very long line of code (a long if statement), can it extend onto two lines? If so how would I do that?

I also wanted to know say I have 7 checkboxes and the condition on my if statement is to check if only one box has been checked, is the only way to do this by having all the different combinations listed?

Thank you for any help, I am fairly new to vb.net and would appreciate any insight!!!
I believe the line continuation character in VB.NET is placing an _ at the end of your line to let the compiler know that the text on the next line needs to be combined with the text from the previous line.

If you are only concerned with the checked status of one checkbox just check to see if that checkbox is checked.

if(CheckBox1.Checked)
{
//do something
}

Nathan
Nov 2 '07 #3
nateraaaa
663 Recognized Expert Contributor
Hi..it's me again.

I tried using a loop to get the count of each checkbox that is check but i don't think that i can use checkboxi.checked (where i is the number of the checkbox) do you always have to state the proper name for the checkbox like checkbox1 instead of checkboxi where i=1?

Thanks again for any help!!!
I am not sure of the setup of your page but if your checkboxes are all in a vertical alignment you could instead use a CheckBoxList and then use a foreach loop to loop through the CheckBoxList to see which CheckBoxes are checked in the CheckBoxList.

For examples on how to do this search Google for the following text:
VB.NET foreach checkbox in checkboxlist

Nathan
Nov 2 '07 #4
balabaster
797 Recognized Expert Contributor
I am not sure of the setup of your page but if your checkboxes are all in a vertical alignment you could instead use a CheckBoxList and then use a foreach loop to loop through the CheckBoxList to see which CheckBoxes are checked in the CheckBoxList.

For examples on how to do this search Google for the following text:
VB.NET foreach checkbox in checkboxlist

Nathan
In answer to your first question...If statement spread over multiple lines (just in case you weren't able to translate from C# to VB)

Expand|Select|Wrap|Line Numbers
  1. If MyStatement1 = True _ 
  2. Or MyStatement2 = True _
  3. Or Mystatement3 = True Then
  4. 'Do stuff
  5. End If
  6.  
In answer to your checkbox loop - validate the check the CheckState property instead of the Checked property.
Nov 2 '07 #5
willywonka
18 New Member
Thanks for all the help...very much appreciated :) !!!!
Nov 2 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Lord Merlin | last post by:
When using "if then" statements in global, I get the following error: a.. Error Type: (0x8002802B) Element not found. //global.asa, line 12 Can I use if then statements in global?
11
by: Khaled Afiouni | last post by:
Hello, How can I stop/prevent SQL server from running compound SQL statements. I do not want the server to run multiple update/delete/insert/select statements as a batch. Is there an option? ...
1
by: Tom D | last post by:
I'm rewriting a database interface that our company currently has. Currently it's using the Pear::DB interface, but we found that that was introducing a bit too much overhead. I'm rewriting the...
6
by: Kenneth | last post by:
Hi Is it possible to see all kinds of executed SQL-statements in a logfile? If yes, how do I do that and how much information does it log? Thanks, Kenneth
7
by: Glenn Davy | last post by:
Hidely hodley everyone I'd like to run a series of of sql ddl statements against an msde2000 server. Normally I just deploy cmd file that impliments as osql statement, but I'd like to store the...
92
by: Raghavendra R A V, CSS India | last post by:
hie.. Do any one knows how to write a C program without using the conditional statements if, for, while, do, switch, goto and even condotional statements ? It would be a great help for me if...
39
by: slogging_away | last post by:
Hi - I'm running Python 2.4.2 (#67, Sep 28 2005, 12:41:11) on win32, and have a script that makes numerous checks on text files, (configuration files), so discrepancies can be reported. The script...
9
by: colin.mcnulty | last post by:
Hi, I'm a SQL Server DBA, but I guess that won't buy me any friends round here huh? ;-) I've been asked to look at the SQL that's being executed on a DB2 database from a web app, specifically...
3
by: Simone | last post by:
Hello I am pretty new to asp.net :) I have a program that loops through a few sql statements and performs inserts. The problem is the sql statements are different for every upcoming new...
7
by: =?Utf-8?B?QVRT?= | last post by:
HOWTO Run multiple SQL statements from ASP/ADO to an Oracle 10g. Please help, I'm trying to write an ASP page to use ADO to run a long query against an Oracle 10g database, to create tables,...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...
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: 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...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.