How to terminate or exit a for loop when the user clicks on stop button
Actually my problem is to stop a loop when i click on stop button.
example:i have two buttons 'start' and 'stop'
in start buttom i wrote a for loop as
dim i as integer
For i=1 To 100000
print i
Next
when i click on start buuton it prints 'i' value up tp 100000.
my question is when i click on 'Stop' button the for loop has to terminate or Exit from the loop and should stops the execution.
Is it possible to termianate or Exit the 'for loop'
PS.Shakeer Hussain
Hyderabad
I am unable to stop the loop and application not at all allowing to Press the Stop button.
It seems like Hung, any advise ?
Private Sub btnStart_Click(sender As Object, e As EventArgs) Handles btnStart.Click
btnStop.Enabled = True
btnSelectFile.Enabled = False
btnStart.Enabled = False
btnStop.Focus()
Dim strFileName As String = txtFileName.Text.ToString
Dim strLineText As String
If System.IO.File.Exists(strFileName) = True Then
Dim objReader As New System.IO.StreamReader(strFileName)
While objReader.Peek() <> -1 And stopclick = False
strLineText = objReader.ReadLine()
MsgBox(strLineText, MsgBoxStyle.Information)
Application.DoEvents()
Thread.Sleep(My.Settings("strDelay") * 1000)
'System.Diagnostics.Process.Start(My.Settings("strFireFoxLocation"), strLineText)
End While
End If
End Sub
Private Sub btnStop_Click(sender As Object, e As EventArgs) Handles btnStop.Click
stopclick = True
btnSelectFile.Enabled = True
btnStart.Enabled = True
btnStop.Enabled = False
End Sub
Raman Katwal
Please remember to mark the replies as answers if they help and unmark them if they provide no help
Similar Messages
-
How to make a text field required at run time when the user clicks the checkbox ?
I got a form where , there are several checkboxes and text fields associated with that checkboxes.If the use clicks on the check box then the associated
text fields should become required.I have tried the change event and the click event for the checkboxes.It gives error in the onChnage event and I got some weird results in the on click event .Sometimes if the user click the check box , then for the 1st time the field doesnt become required , then the user onclicks the check box and when the user clicks the checkbox for the second time the field becomes required,but if i deselects the highlighted field option and selects it again the field becomes required even if the user onchecks it I am totally confused !!! Adding to it i have also written the wrong code still i achieved the desired result ?? How it can be possible . I am writing the codes below , please help me as i am working under a deadline from the client.
onChange event :
var newVal = this.boundItem(xfa.event.newText);
if(newVal == 0)
xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row4.Purchasecost3_1" ).validate.nullTest = "disabled";
else
xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row4.Purchasecost3_1" ).validate.nullTest = "error";
For the onClick event :
var a = xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row2.CostItemRecovere d_OnlyEnergyCharges").rawValue;
//app.alert(a);
if(a == 0)
xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row4.ComplianceCheck_ L1_1").validate.nullTest = "error";
if(a == 1)
xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row4.ComplianceCheck_ L1_1").validate.nullTest = "disabled";
Please help someone !!!I used the onchange event and wrote the code for it. I got the result . But there is a problem.All these fields are in a table and it's a dynamic table where you can add rows dynamically at the run time .I have other change event for some fields in this table .All are working fine when i add the row.But for this check box the required fields are not validated as required at the run time . I am here giving the code , Please help me .
form1.Subform0.Subform1.Subform9.Subform10.Table48.Row2.CostItemRecovered_OnlyEnergyCharge s::change - (JavaScript, client)
if(this.rawValue == "1")
xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row4.ComplianceCheck_ L1_1").mandatory= "error";
xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row4.ComplianceCheck_ L2_1").mandatory= "error";
xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row5.ComplianceCheck_ L1_2").mandatory= "error";
xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row5.ComplianceCheck_ L2_2").mandatory= "error";
xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row6.ComplianceCheck_ L1_3").mandatory= "error";
xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row6.ComplianceCheck_ L2_3").mandatory= "error";
xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row7.ComplianceCheck_ L1_4").mandatory= "error";
xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row7.ComplianceCheck_ L2_4").mandatory= "error";
xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row8.ComplianceCheck_ L1_5").mandatory= "error";
xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row8.ComplianceCheck_ L2_5").mandatory= "error";
else
xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row4.ComplianceCheck_ L1_1").mandator = "disabled";
xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row4.ComplianceCheck_ L2_1").mandatory = "disabled";
xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row5.ComplianceCheck_ L1_2").mandatory = "disabled";
xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row5.ComplianceCheck_ L2_2").mandatory = "disabled";
xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row6.ComplianceCheck_ L1_3").mandatory = "disabled";
xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row6.ComplianceCheck_ L2_3").mandatory = "disabled";
xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row7.ComplianceCheck_ L1_4").mandatory = "disabled";
xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row7.ComplianceCheck_ L2_4").mandatory = "disabled";
xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row8.ComplianceCheck_ L1_5").mandatory = "disabled";
xfa.resolveNode("form1.Subform0.Subform1.Subform9.Subform10.Table48.Row8.ComplianceCheck_ L2_5").mandatory = "disabled"; -
How do I call a method when the user clicks on the delete button?
Hello , I need to implement the following :
If date from is less than sysdate , when the user clicks the "delete" button , he is shown an error message .
Can you please help how this can be done ? Thanks.Thanks. What are the steps for adding a custom delete button ?
Are these ok ?
1 ) Add an adf button
2) Add the following in the actions listener : #{bindings.Delete.execute}
3) Right Click button --> create method binding for action
4) Compare date ?
Thanks. -
I put a glossary button in my project. When the user clicks on the button, I want the file to open in a new browser window. This works in preview mode, but not when I publish it. What am I doing wrong?
I've tried the download three times. It reports that installation was successful, but when I use Firefox I still get only an option to download the .pdf; I still can't read it within the browser. This fix WAS for Firefox 5.0, right?
-
How can I create a scrolling effect where when the user scrolls down the image will blur out?
How can I create a scrolling effect where when the user scrolls down the image will blur out?
Hi there,
You can create a scroll motion where the image will fade out on scrolling, you need to use the Opacity tab under Scroll Effects Panel.
If you particularly need the image to be blur out, then you need to edit that image in any image editing program and make one copy of that image as blurred, then place both images (actual and blurred) on that page and use scroll motion or fade option to replace images. -
Sorry if that's confusing, but like how for example, you have:
ADDRESS: _________________________ +another address
& then if the user typed in information into the address field and wanted another address, it would look like:
ADDRESS: __________________________
ADDRESS: __________________________ +another address
& so on... is there a way to do this?What you want is something like this
http://dynamicdrive.com/dynamicindex16/chainedselects/index.htm -
Looping until the user wants to stop
Hey everyone. I have been racking my brain around this and cannot find the problem. I want this following loops to run as long as the use enters 'yes' at the end of it. This loops worked fine once before, I don't understand why it isn't working now. I need an outsiders view to help me out!! =)
do
System.out.println("Please enter a sentence with end punctuation: ");
oneLineInput = keyboard.nextLine();
inputLength = oneLineInput.length();
endPunctuation1 = oneLineInput.indexOf("?");
endPunctuation2 = oneLineInput.indexOf("!");
evenOrOdd = inputLength % 2;
if (endPunctuation1 != -1 || endPunctuation2 != -1)
if (endPunctuation2 != -1)
System.out.println("Wow");
System.out.print("Do you want to run the program again? ");
repeat = keyboard.next();
else
if (evenOrOdd == 0)
if (endPunctuation1 != -1)
System.out.println("Yes");
System.out.print("Do you want to run the program"
+ "again? ");
repeat = keyboard.next();
else
if (endPunctuation1 != -1)
System.out.println("No");
System.out.print("Do you want to run the program"
+ "again? ");
repeat = keyboard.next();
else
System.out.println("You always say " + "\"" + oneLineInput + "\"");
System.out.print("Do you want to run the program again? ");
repeat = keyboard.next();
while (repeat.equalsIgnoreCase("yes"));With all due respect I was referring to the the input working not the loops repeating itself. The way that I had it I could get the input, but it would not loop. The input is what I was referring to as working. Just because it was messy meant nothing. But here is the revised code
import java.util.*;
public class OneLineSentence
public static void main(String[] args)
Scanner keyboard = new Scanner(System.in);
String oneLineInput, repeat;
int inputLength, endPunctuation1, endPunctuation2, evenOrOdd;
do
System.out.println("Please enter a sentence with end punctuation: ");
oneLineInput = keyboard.nextLine();
inputLength = oneLineInput.length();
endPunctuation1 = oneLineInput.indexOf("?");
endPunctuation2 = oneLineInput.indexOf("!");
evenOrOdd = inputLength % 2;
if (endPunctuation1 != -1 || endPunctuation2 != -1)
if (endPunctuation2 != -1)
System.out.println("Wow");
System.out.print("Do you want to run the program again? ");
repeat = keyboard.next();
else
if (evenOrOdd == 0)
if (endPunctuation1 != -1)
System.out.println("Yes");
else
if (endPunctuation1 != -1)
System.out.println("No");
else
System.out.println("You always say " + "\"" + oneLineInput + "\"");
System.out.print("Do you want to run the program again? ");
repeat = keyboard.next();
while (repeat.equalsIgnoreCase("yes"));
}} -
I'm developing a process-control application,using serial communication for data acquisition. My problem - I need this serial read of data to be continuous. But, when I click on a drop-down menu, the rest of the processing halts until I click on one of the menu items in the drop-down list and I lose data in that interval. What can I do?
In most process-control applications it is not about just avoiding lost measurement data. The most important is having a robust control-algoritm that reacts to a change of input-situation in a given time.
A non-responsive system is not a very reliable process-control solution.
The vi you mentioned are only around since the latest versions and the old method of polling controls still suits many applications (but that's another discussion).
As about RS-232 input time-outs, I have never used that.
In the time before VISA was created I (as other LabVIEW users I discovered) used a method of storing every incoming string in a buffer (memory-vi with USR) and that still works (classic serial VI's versus VISA is also another never-ending discussio
n). -
How do you make a video automatically play when the user gets to a certain point/pixel?
I'm trying to create a website with a video embedded in using the YouTube widget. I want the video to start playing when the top of the widget reaches the top of the screen, in this case at 400 pixels. Can anyone help? Thank you in advance!
Provide the name of the program you are using so a Moderator may move this message to the correct program forum
This Cloud forum is not about help with program problems... a program would be Photoshop or Lighroom or Muse or ??? -
In adf,how to delete a file generated on server,when the webpage is closed
Hi,
I have an application consisting of 2 pages. in the 1st page i will give some input details and when i click on submit, some java code is getting executed in the back. That java code generates a csv file in the server location. after succesful execution of java code, i was redirected to 2nd page. In 2nd page, i am giving option to download and when the user clicked on download button and after the file is downloaded -- in the backend i am deleting the file from the server. Till this point everything is fine. But if the user didnt click on the Download button and instead if he closes the browser, the csv file gets remained on the server itself. This is the issue i am facing .. I am not able to get an idea in ADF Framework, how to delete a file when the browser is closed. Please help me out in this.
Thanks in advance !!!ADF has nothing to do with tracking browser close buttons. What you can do is call a JS function and call the method which deletes the file from within the JS function. ADF has a component for calling java code from JS call.
-
How do I run a video in one cell of a table when a user clicks a button in another cell?
In other words, I want to put 3 buttons in one cell of a table so that the user can run one of three Flash videos in a cell beside the buttons. How do I do that?
Header 1
Header 2
button 1 runs video 1
button 2 runs video 2
button 3 runs video 3
video 1, 2, or 3 is inserted here when the user clicks the buttonYou will have better luck if you find a Flash Player that uses a playlist. Direct links to FLV files don't work.
http://www.wimpyplayer.com/
http://www.woosterwebdesign.com/flvplayer/
http://www.longtailvideo.com/players/jw-flv-player/
http://flowplayer.org/
Another option is to upload your videos to YouTube.com. You can customize a YouTube player and populate it with videos you specify. Then paste their player embed code into your web page.
http://code.google.com/apis/youtube/getting_started.html
Nancy O.
Alt-Web Design & Publishing
Web | Graphics | Print | Media Specialists
http://alt-web.com/
http://twitter.com/altweb -
How to let " i " of a for loop to start from a "X"
Hi,
how to let " i " of a for loop to start from a value "x" where x is a variable?
Thx
Message Edited by starfish on 10-19-2007 06:00 AMHi starfish,
use it like this:
If this doesn't fit your needs you should attach an example of what you really need!
Message Edited by GerdW on 10-19-2007 01:15 PM
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome
Attachments:
I.png 2 KB -
Stopping output tasks properly before exiting a For-loop
Hi,
I've been having some trouble exiting a For-loop conditionally. The problem is that when the loop is stopped conditionally (a button is pressed) the DAQ (NI USB 6353) outputs get stuck to whatever value they were in. I tried stopping the DAQ Assistant output task (1 sample on demand) before exiting the loop but that didn't solve the problem. Should this perhaps be done one iteration before exiting the loop or can it be done in the same iteration round?
What would be the "right" way to exit a for loop with output tasks so that the output signals would be 0V after exiting? I know that I could "force" feed the DAQ Assistant with 0V control before exiting but in this case that would be quite difficult...
Any ideas? Help is appriciated.Yes, I get it... However at this point I don't think that's an option.
Would this kind of solution work? ( I am not able to test all possible solutions in the real system which is why I would like to get a confirmation first)
The idea is to connect the output of the "Or" port to the "Stop" -ports of the DAQ Assistants in the loop.
Edit. Will the output automatically go to 0V if I just stop the task? I am not really sure about this.
Thank you.
Attachments:
exit-loop.jpg 8 KB -
How to pass parameter to cursor for loop having table type?
Hi Friends,
I am wondering how to pass a parameter into second for loop in the example code below.Please see the bold statements and answer my queries.
Thanks a lot .Here is the code .
declare
l_bom_header_tbl BOM_BO_PUB.BOM_HEADER_TBL_TYPE ; ---TABLE TYPE
V_bom_header_tbl Bom_Bo_Pub.Bom_Head_Rec_Type := Bom_Bo_Pub.G_MISS_BOM_HEADER_REC; ---Record type
v_bom_components_tbl Bom_Bo_Pub.Bom_Comps_Tbl_Type := Bom_Bo_Pub.G_MISS_BOM_COMPONENT_TBL;---nested table type
c:=0 number ;
k:=1 number ;
begin
BOMPXINQ.Export_BOM(
P_org_hierarchy_name => l_org_hierarchy_name,
P_assembly_item_name => l_assembly_item_name,
P_organization_code => l_organization_code,
P_alternate_bm_designator => '1Test',
P_Costs => l_costs,
P_Cost_type_id => l_cost_type_id,
X_bom_header_tbl => l_bom_header_tbl,
X_bom_revisions_tbl => l_bom_revisions_tbl,
X_bom_components_tbl => l_bom_components_tbl,
X_bom_ref_designators_tbl => l_bom_ref_designators_tbl,
X_bom_sub_components_tbl => l_bom_sub_components_tbl,
X_bom_comp_ops_tbl => l_bom_comp_ops_tbl,
X_Err_Msg => l_Err_Msg,
X_Error_Code => l_Error_Code);
if l_Error_Code = 0 then
for i in 1 .. l_bom_header_tbl.COUNT LOOP
V_bom_header_tbl.organization_code :='DSC';
Can we assign a table type to record type like below statement?
V_bom_header_tbl.assembly_item_name:= l_bom_header_tbl(i).assembly_item_name ;
k:=1;
I want to pass parameter l_bom_header_tbl(i).assembly_item_name into the for statement below: How to achieve this?
for j in 1 .. l_bom_components_tbl.COUNT LOOP
Can we assign a table type to table type like below statement?
v_bom_components_tbl(k).Assembly_Item_name := l_bom_header_tbl(i).assembly_item_name ;
k := k + 1;
end LOOP;
end loop;
end;
Edited by: ILovePlSql on Mar 22, 2010 7:51 AM
Edited by: ILovePlSql on Mar 22, 2010 8:16 AMILovePlSql wrote:
V_bom_header_tbl.assembly_item_name:= l_bom_header_tbl(i).assembly_item_name ;
v_bom_header_tabl is a record type and l_bom_header_tbl is a table type .So is the above statement ok?I asked you for type definition. Please provide definition of BOM_BO_PUB.BOM_HEADER_TBL_TYPE and Bom_Bo_Pub.Bom_Head_Rec_Type. If BOM_BO_PUB.BOM_HEADER_TBL_TYPE is table of Bom_Bo_Pub.Bom_Head_Rec_Type then your statment is OK. For example:
SQL> declare
2 type BOM_HEADER_TBL_TYPE is table of emp%rowtype index by binary_integer;
3 l_bom_header_tbl BOM_HEADER_TBL_TYPE;
4 V_bom_header_tbl emp%rowtype;
5 begin
6 select * bulk collect into l_bom_header_tbl from emp;
7 for i in 1 .. l_bom_header_tbl.count loop
8 V_bom_header_tbl.ename := l_bom_header_tbl(i).ename;
9 end loop;
10 end;
11 /
PL/SQL procedure successfully completed.
SQL> SY. -
Nested for loop in the collections
Hi Experts,
collection1
============
SELECT o.object_id
BULK COLLECT INTO l_obj_info
FROM (SELECT n.node_id, n.object_id
FROM nodes n
START WITH n.node_id = 100
CONNECT BY PRIOR n.node_id = n.parent_node_id) n
INNER JOIN
objects o ON n.object_id = o.object_id
WHERE o.object_type_id = 285;
collection2
============
SELECT *
BULK COLLECT INTO l_tab
FROM ((SELECT REGEXP_SUBSTR (i_l_text, '[^,]+', 1, LEVEL)
FROM DUAL
CONNECT BY REGEXP_SUBSTR (i_l_text, '[^,]+', 1, LEVEL) IS NOT NULL));
END;
collection3
============
SELECT o.object_id
BULK COLLECT INTO l_fin_tab
FROM objects o JOIN ATTRIBUTES att
ON o.object_id = att.object_id
WHERE o.object_id = collection1.object_id
--AND att.VALUE = collection2.val;
Please tell me how to implement for loop in the collection3 to get the values from collection1 and collection2.
i have tried in the below way
CREATE OR REPLACE TYPE LIST_OF_ATTRIBUTES_TYPE AS TABLE OF varchar2(4000);
CREATE OR REPLACE TYPE LIST_OF_OBJECT_IDS_TYPE AS TABLE OF number(9);
CREATE OR REPLACE FUNCTION f_get_objects_by_type_id (
i_object_type_id IN NUMBER,
i_l_text IN VARCHAR2,
i_scope_node_id NUMBER
RETURN list_of_object_ids_type
AS
CURSOR objs_info
IS
SELECT o.object_id
FROM (SELECT n.node_id, n.object_id
FROM nodes n
START WITH n.node_id = i_scope_node_id
CONNECT BY PRIOR n.node_id = n.parent_node_id) n
INNER JOIN
objects o ON n.object_id = o.object_id
WHERE o.object_type_id = i_object_type_id;
l_tab list_of_attributes_type := list_of_attributes_type ();
--l_obj_info list_of_object_ids_type := list_of_object_ids_type ();
l_fin_tab list_of_object_ids_type := list_of_object_ids_type ();
BEGIN
BEGIN
SELECT *
BULK COLLECT INTO l_tab
FROM ((SELECT trREGEXP_SUBSTR (i_l_text, '[^,]+', 1, LEVEL)
FROM DUAL
CONNECT BY REGEXP_SUBSTR (i_l_text, '[^,]+', 1, LEVEL) IS NOT NULL));
END;
IF l_tab.COUNT > 0
THEN
FOR i IN objs_info
LOOP
FOR j IN l_tab.FIRST .. l_tab.LAST
LOOP
SELECT o.object_id
BULK COLLECT INTO l_fin_tab
FROM objects o JOIN ATTRIBUTES att ON o.object_id =
att.object_id
WHERE
att.VALUE = l_tab (j) and o.object_id =objs_info(i);
END LOOP;
END LOOP;
END IF;
RETURN l_fin_tab;
END f_get_objects_by_type_id;Why are you wanting to do this?
It looks like you are trying to implement SQL joins in PL code. Not only is that using up expensive PGA memory by storing the data in collections, but doing such retrieval of data to try and join it in PL loops, is never going to be as fast as just joining the SQL queries using SQL itself.
Post some example data and your database version, with an example of what the output should look like from that example data.
Re: 2. How do I ask a question on the forums?
Maybe you are looking for
-
FACE TIME with new Snow Leopard
I am currrently running Leopard 10.5.8 right now and i tried to download FaceTime on my computer...but found out that it doesn't work....because you need to upgrade to Snow Leopard?... so if i get the upgrade.... will it install smoothly? and let me
-
I can't get photos sorted in order, please help
Hi, As the title says when I sync my photos to my iphone (and ipad) they are not in the same order as on my Mac. I've done a bit of research and I've found out that the iDevices sort photos by date rather than by name if you sync from a folder. Howev
-
I reinstalled the software of the Ibook G4 but now Safari doesn't open anymore. I tried a lot already to open Safari but it does't do anything anymore. Can someone please help me?
-
Webcam not active in tochsmart video application
when i start my touchsmart video application the webcam button on bottom of screen will not highlight or not activate on my hp IQ500
-
CS6 hangs during infuriatingly simple tasks
For the fifth time today, Premiere has hung on me. Fifth time today, and probably the ninth time in this project. I'm working solely on H.264 Canon 600D .movs, no fancy effects, no third party plug-ins, just a straight forward edit with some standard