|
-
April 25th, 2007, 05:24 AM
#1
Problem with calling a case statement from a case statement
i am trying to call a case statement from a case statement..it is throwing an error
if u can tell me where i am getting wrong
Select Case strOper
Case "Search for Product"
.ClearToQuery
.SetViewMode 3
.SetSearchSpec "Name", strProduct
.ExecuteQuery 1
strInstep = "Step 5:Checking for Product Name existence"
If .FirstRecord = strProduct Then
Goto Case "Search for Cost List"---------------it throws error here
-
April 25th, 2007, 06:10 AM
#2
Re: Problem with calling a case statement from a case statement
Hi poshyradha
It is better to send more complete code snippets and within code tags.
anyway, using goto is discouraged. It causes what is know as spaghetti code, the code that is hard to follow and trace.
you better refactor your code and move the actions in Case "Search for Product" block to another function or method and call it.
-
April 25th, 2007, 06:24 AM
#3
Re: Problem with calling a case statement from a case statement
Using Goto is not a good practice. It seems you want to execute another block of statements from the same case. As suggested refactor your code and also, post the complete code block, not just the line that is giving an error.
-
April 26th, 2007, 03:14 AM
#4
Re: Problem with calling a case statement from a case statement
Poshyradha
Do you have a CASE called "Search for Cost List"?
Or just "Cost List"?
-
April 26th, 2007, 04:38 AM
#5
Re: Problem with calling a case statement from a case statement
[ cleaned ]
Folks, it is important to post content relevant to the topic under discussion.
To discuss issues that donot concern the thread, please use "Private Messaging". If you have problems, approach a Moderator.
Regards,
Siddhartha
Last edited by Siddhartha; April 26th, 2007 at 04:54 AM.
-
April 26th, 2007, 12:47 PM
#6
Re: Problem with calling a case statement from a case statement
Well first of all your using the Goto Incorectly...
You need to define a Line Lable for the goto to jump too..
Code:
Select Case strOper
Case "Search for Product"
......
.ClearToQuery
.SetViewMode 3
.SetSearchSpec "Name", strProduct
.ExecuteQuery 1
strInstep = "Step 5:Checking for Product Name existence"
If .FirstRecord = strProduct Then
'Goto Case "Search for Cost List"---------------it throws error here
Goto Next_Step
.....
Case "Search for Cost List"
Next_Step:
.......
You define lables in code by preceeding (err following) them with a ':' ..
Gremmy...
Last edited by GremlinSA; April 27th, 2007 at 06:55 AM.
Reason: correct code...
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
-
April 26th, 2007, 01:35 PM
#7
Re: Problem with calling a case statement from a case statement
 Originally Posted by GremlinSA
You define lables in code by preceeding them with a ':' ..
Gremmy...
You define labels in code with a ':' after the label text.
Code:
'...
Exit Sub
ErrorOccured:
MsgBox Err.Description
'...
Starting with a ':' makes VB believe it's a blank statement.
-
April 26th, 2007, 06:28 PM
#8
Re: Problem with calling a case statement from a case statement
Starting with a : is the same as the LINE CONTINUATION symbol. It's treated as nothing other than a new statement. It's not ignored.
Ending with a ":" makes it a line label, and moves it to the far left.
Code:
Option Explicit
Private Sub Form_Load()
Dim a
: a = 2
MsgBox a
End Sub
-
April 27th, 2007, 06:51 AM
#9
Re: Problem with calling a case statement from a case statement
Ooooppss..
 Originally Posted by dglienna
Ending with a ":" makes it a line label, and moves it to the far left.
You are so right...
I dont usually use line lables... and got a little mixed up... I'm too stupid...
Gremmy...
Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
WPF Articles : 3D Animation 1 , 2 , 3
Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|