473,326 Members | 2,732 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,326 software developers and data experts.

Skipping to a line of code

Is there a way to skip to a line of code in VB?

Say i have something like this

Expand|Select|Wrap|Line Numbers
  1. 1   If txtCandidates.Text = 5 Then
  2. 2     If txtCount1.Text > txtVotes.Text / 2 Then
  3. 3     MsgBox ("Candidate 1 has the absolute majority, therfore candidate 1 is the winner")
  4. 4     Else
  5. 5       If txtCount2.Text > txtVotes.Text / 2 Then
  6. 6       MsgBox ("Candidate 2 has the absolute majority, therfore candidate 2 is the winner")
  7. 7       Else
  8. 8         If txtCount3.Text > txtVotes.Text / 2 Then
  9. 9         MsgBox ("Candidate 3 has the absolute majority, therfore candidate 3 is the winner")
  10. 10       Else
  11. 11         If txtCount4.Text > txtVotes.Text / 2 Then..........
I added the numbers to represent the lines of code.

I want to write an If statement like "If txtcount1 = 0 then skip to line 5"

is this possible?
Mar 10 '07 #1
4 1689
willakawill
1,646 1GB
Hi it is called the GoTo statement and it is normally only used for errors. If you need it in your code you are doing something wrong :)
Mar 10 '07 #2
Hi it is called the GoTo statement and it is normally only used for errors. If you need it in your code you are doing something wrong :)
Oh you're right. Thank you.
I dont need to use it in my code.
Mar 10 '07 #3
markmcgookin
648 Expert 512MB
Is there a way to skip to a line of code in VB?

Say i have something like this

Expand|Select|Wrap|Line Numbers
  1. 1   If txtCandidates.Text = 5 Then
  2. 2     If txtCount1.Text > txtVotes.Text / 2 Then
  3. 3     MsgBox ("Candidate 1 has the absolute majority, therfore candidate 1 is the winner")
  4. 4     Else
  5. 5       If txtCount2.Text > txtVotes.Text / 2 Then
  6. 6       MsgBox ("Candidate 2 has the absolute majority, therfore candidate 2 is the winner")
  7. 7       Else
  8. 8         If txtCount3.Text > txtVotes.Text / 2 Then
  9. 9         MsgBox ("Candidate 3 has the absolute majority, therfore candidate 3 is the winner")
  10. 10       Else
  11. 11         If txtCount4.Text > txtVotes.Text / 2 Then..........
I added the numbers to represent the lines of code.

I want to write an If statement like "If txtcount1 = 0 then skip to line 5"

is this possible?
I would use CASE statements for this instead of IFs, or combine it into one ELSE statement, with a number of ELSE IFs
Mar 10 '07 #4
Killer42
8,435 Expert 8TB
Oh you're right. Thank you.
I dont need to use it in my code.
Although some earlier versions of BASIC made it almost impossible to do without, these days the GoTo statement is generally viewed as a sign of poor design. There are various control structures built into most languages which make it unnecessary, and are generally less confusing.
Mar 12 '07 #5

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

Similar topics

9
by: Chuck Anderson | last post by:
I have a function with 7 inputs. The last three have default values. I want to call that function specifying the first four, skip two and then specify the last. I thought I could write this...
1
by: Rick | last post by:
After being frustrated with this issue on several occasions I think I found the secret sauce for solving the issue after reading a few different messages about what others thought and trying a...
5
by: Geoff Bennett | last post by:
While parsing an XML document, my TextReader instance skips nodes. For example, in this fragment: <Person Sex="Male" FirstHomeBuyer="No" YearsInCurrentProfession="14"> <RelatedEntityRef...
3
by: Ivan Liu | last post by:
I would like know how I can skip a line while reading a set of input data (from a text file) if the first character of the line is "#". My original code reads: ifstream Infile("data.dat"); ...
11
by: cindyfaith | last post by:
I have one question regarding a code I wrote to parse a data file My code looks like this open($FILE, "C:\\data\\NCI sample.txt") or die "oh oh can't open"; open(OUT,...
7
by: Gustaf | last post by:
Hi all, Just for fun, I'm working on a script to count the number of lines in source files. Some lines are auto-generated (by the IDE) and shouldn't be counted. The auto-generated part of files...
3
by: zeroblade | last post by:
How do you stop paragraph tags from skipping a line when after the </p> tag?
0
by: Jerry Coffin | last post by:
In article <4fae62b0-6858-4e9e-830e-9eecf6691d4a@ 59g2000hsb.googlegroups.com>, friend.blah@googlemail.com says... Each time you read from the file, keep track of the file position after...
4
by: BibI | last post by:
Hi there, I just started programming with PERL and am trying to put together my first little data manipulation program. I am working on a MAC with OSX. I have a data file with the following...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
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...

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.