Search Results

Search found 834 results on 34 pages for 'looping'.

Page 5/34 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Looping through a file in VB.NET

    - by Ousman
    I am writing a VB.NET program and I'm trying to accomplish the following: Read and loop through a text file line by line Show the event of the loop on a textbox or label until a button is pressed The loop will then stop on any number that happened to be at the loop event and When a button is pressed again the loop will continue. Code Imports System.IO Public Class Form1 'Dim nFileNum As Integer = FreeFile() ' Get a free file number Dim strFileName As String = "C:\scb.txt" Dim objFilename As FileStream = New FileStream(strFileName, _ FileMode.Open, FileAccess.Read, FileShare.Read) Dim objFileRead As StreamReader = New StreamReader(objFilename) 'Dim lLineCount As Long 'Dim sNextLine As String Private Sub btStart_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles btStart.Click Try If objFileRead.ReadLine = Nothing Then MsgBox("No Accounts Available to show!", _ MsgBoxStyle.Information, _ MsgBoxStyle.DefaultButton2 = MsgBoxStyle.OkOnly) Return Else Do While (objFileRead.Peek() > -1) Loop lblAccounts.Text = objFileRead.ReadLine() 'objFileRead.Close() 'objFilename.Close() End If Catch ex As Exception MessageBox.Show(ex.Message) Finally 'objFileRead.Close() 'objFilename.Close() End Try End Sub Private Sub Form1_Load(ByVal sender As System.Object, _ ByVal e As System.EventArgs) _ Handles MyBase.Load End Sub End Class Problem I'm able to read the text file but my label will only loop if I hit the start button. It goes to the next line, but I want it to continue to loop through the entire file until I hit a button telling it to stop.

    Read the article

  • Looping through macro Varargs values

    - by Ed Marty
    If I define some macro: #define foo(args...) ({/*do something*/}) Is there some way to actually loop through args rather than pass it along to another function? Something like #define foo(args...) \ { \ for (int i = 0; i < sizeof(args); ++i) { \ /*do something with args[i]*/ \ } \ }

    Read the article

  • looping through variable post vars and adding them to the database

    - by Neil Hickman
    I have been given the task of devising a custom forms manager that has a mysql backend. The problem I have now encountered after setting up all the front end, is how to process a form that is dynamic. For E.G Form one could contain 6 fields all with different name attributes in the input tag. Form two could contain 20 fields all with different name attributes in the input tag. How would i process the forms without using up oodles of resource.

    Read the article

  • Problem while looping on a NSDictionary

    - by Tom
    Hi! The end of my loop causes a EXC_BAD_ACCESS. Here's my dictionary (AppDelegate.data): 1 = ( 3, "Test 1", False, "" ); 2 = ( 4, "Test 2", False, "" ); And here is my loop: for (id theKey in AppDelegate.data) { if (theKey = nil) { NSLog(@"HOLY COW"); } else { NSLog(@"Key: %@ ?", theKey); } } It never says holy cow, and it says the right key but at the end it crashes... Do you have any idea why? It should only loop on 1 and two and then exit the loop... I know that there's always a "nil" object at the end that's why I did a condition with it but it doesn't look like it works at all.. Thanks!

    Read the article

  • looping through JSON array

    - by Phil Jackson
    Hi all. I have recently posted another question which straight away users pointed me in the right direction. $.ajax({ type: 'POST', url: './', data: 'token=' + token + '&re=8', cache: false, timeout: 5000, success: function(html){ auth(html); var JSON_array = eval(html); alert(JSON_array[0].username); } }); this returns the data correctly but I want to perform a kind of 'foreach'. the array contains data about multiple incoming and outgoing Instant Messages. So if a user is talking to more than one person at a time i need to loop through. the array's structure is as follows. Array ( [0] => Array ( [username] => Emmalene [contents] => <ul><li class="name">ACTwebDesigns</li><li class="speech">helllllllo</li></ul> <ul><li class="name">ACTwebDesigns</li><li class="speech">sds</li></ul> <ul><li class="name">ACTwebDesigns</li><li class="speech">Sponge</li><li class="speech">dick</li></ul> <ul><li class="name">ACTwebDesigns</li><li class="speech">arghh</li></ul> ) ) any help very much appreciated.

    Read the article

  • LINQ VB.NET variable not found when looping through grouped query

    - by Ed Sneller
    I'm trying to do the following LINQ grouping, which works in the debugger (the results are populated in the GroupedOrders object. But VS 2008 gives me the following error at design time... Name 'x' is not declared Dim GroupedOrders = (From m In thisConsultant.orders _ Group m By Key = m.commCode Into Group _ Select commCode = Key, orders = Group) For Each x In GroupedOrders Next VS 2008 gives me the following error,

    Read the article

  • PHP Looping....need some advice

    - by Homer_J
    Hi all, I have the following code: $q1 = $_POST["q1"]; $q2 = $_POST["q2"]; $q3 = $_POST["q3"]; $q4 = $_POST["q4"]; $q5 = $_POST["q5"]; $q6 = $_POST["q6"]; $q7 = $_POST["q7"]; $q8 = $_POST["q8"]; At the moment, this is hard coded and I need to manually change it each time, I'd like to use variables instead so that it's not a manual process. Is it a case of using a loop, while or foreach? If I had the the information $q and q in an array would that help? Thanks, Homer.

    Read the article

  • VB working with SQL DB - end of row count, keeps looping

    - by Tramd
    I'm adding to a combo box an ID and a name that i'm pulling from a database. My problem is that for some reason my loop doesnt end once it reaches the end of the records in the database table. Here's my code: For intcount = 0 To dtOrders.Rows.Count - 1 cmbSearch.Items.Add(dtOrders.Rows(intcount)("EmployeeID").ToString & " " & dtOrders.Rows(intcount)("EmployeeLastName").ToString & ", " & dtOrders.Rows(intcount)("EmployeeFirstName").ToString) Next Shouldnt the .rows.count - 1 stop it once it reaches the last record? It loops 4 times through.

    Read the article

  • Looping through a directory on the web and displaying its contents (files and other directories) via

    - by al jaffe
    In the same vein as http://stackoverflow.com/questions/2593399/process-a-set-of-files-from-a-source-directory-to-a-destination-directory-in-pyth I'm wondering if it is possible to create a function that when given a web directory it will list out the files in said directory. Something like... files[] for file in urllib.listdir(dir): if file.isdir: # handle this as directory else: # handle as file I assume I would need to use the urllib library, but there doesn't seem to be an easy way of doing this, that I've seen at least.

    Read the article

  • Looping an animation made with script.aculo.us

    - by Dan T
    I've created an animation using script.aculo.us. However, when the animation is finished, I want to have it reset all the objects and perform the animation again. I plan to just reset the positions of the objects manually, but how can I make the animations loop? If I put the effect declarations inside a for or while loop, it just crashes the browser. Any ideas?

    Read the article

  • using Label control to create looping marquee text in c# winform

    - by hanmyint
    I have been create Marquee text using Label control her is sample code public partial class FrmMarqueeText : Form { private int xPos = 0, YPos = 0; public FrmMarqueeText() { InitializeComponent(); } private void FrmMarqueeText_Load(object sender, EventArgs e) { lblText.Text = "Hello this is marquee text"; xPos = lblText.Location.X; YPos = lblText.Location.Y; timer1.Start(); } private void timer1_Tick(object sender, EventArgs e) { if (xPos == 0) { this.lblText.Location = new System.Drawing.Point(this.Width, YPos); xPos = this.Width; } else { this.lblText.Location = new System.Drawing.Point(xPos, YPos); xPos -= 2; } } but when the first time was finished, it didn't continues work .Please help me!

    Read the article

  • php and mysql listing databases and looping through results

    - by Jacksta
    Beginner help needed :) I am doign an example form a php book which lists tables in databases. I am getting an error on line 36: $db_list .= "$table_list"; <?php //connect to database $connection = mysql_connect("localhost", "admin_cantsayno", "cantsayno") or die(mysql_error()); //list databases $dbs = @mysql_list_dbs($connection) or die(mysql_error()); //start first bullet list $db_list = "<ul>"; $db_num = 0; //loop through results of functions while ($db_num < mysql_num_rows($dbs)) { //get database names and make each a list point $db_names[$db_num] = mysql_tablename($dbs, $db_num); $db_list .= "<li>$db_names[$db_num]"; //get table names and make another list $tables = @mysql_list_tables($db_names[$db_num]) or die(mysql_error()); $table_list = "<ul>"; $table_num = 0; //loop through results of function while ($table_num < mysql_num_rows($tables)){ //get table names and make each bullet point $table_names[$table_num] = mysql_tablename($tables, $table_num); $table_list .= "<li>$table_names[$table_num]"; $table_num++; } //close inner bullet list and increment number to continue $table_list .= "</ul>" $db_list .= "$table_list"; $db_num++; } //close outer bullet list $db_list .= "</ul>"; ?> <html> <head> <title>MySQL Tables</title> </head> <body> <p><strong>Data bases and tables on local host</strong></p> <? echo "$db_list"; ?> </body>

    Read the article

  • Looping through Markers with Google Maps API v3 Problem

    - by Oscar Godson
    I'm not sure why this isn't working. I don't have any errors, but what happens is, no matter what marker I click on, it clicks the 3rd one (which is the last one out of 4 markers. Array starts at 0, obviously) and shows the number "3", which is correct for THAT one, but I'm not clicking that one. Here is most of my code, just not the array of [place-name, coordinates] (var locations, which you will see): function initialize() { var latlng = new google.maps.LatLng(45.522015,-122.683811); var settings = { zoom: 15, center: latlng, disableDefaultUI:true, mapTypeId: google.maps.MapTypeId.SATELLITE }; var map = new google.maps.Map(document.getElementById("map_canvas"), settings); var infowindow = new Array(); var marker = new Array(); for(x in locations){ console.log(x); infowindow[x] = new google.maps.InfoWindow({content: x}); marker[x] = new google.maps.Marker({title:locations[x][0],map:map,position:locations[x][1]}); google.maps.event.addListener(marker[x], 'click', function() {infowindow[x].open(map,marker[x]);}); } } initialize() The console.log output is (its correct, and what i expect): 0 1 2 3 So, any ideas?

    Read the article

  • Looping through an List to select an Element in Selenium

    - by ChrisMcLellan
    I'm attempting to write a Page Class for Links within the Header of the website I'm testing. I have the following link structure below <ul> <li><a href="/" title="Home">Home</a></li> <li><a href="/AboutUs" title="About Us">About Us</a> </li> <li><a href="/Account" title="Account">Account</a></li> <li><a href="/Account/Orders" title="Orders">Orders</a></li> <li><a href="/AdministrationPortal" title="Administration Portal">Administration Portal</a></li> </ul> What I want to do is store these into a List, then when a user select one of the links, it will take then to the page they should go to. I have started with the following code below List<IWebElement> headerElements = new List<IWebElement>(); headerElements.Add(WebDriver.FindElement(By.LinkText("Home"))); headerElements.Add(WebDriver.FindElement(By.LinkText("About Us"))); headerElements.Add(WebDriver.FindElement(By.LinkText("Account"))); headerElements.Add(WebDriver.FindElement(By.LinkText("Orders"))); headerElements.Add(WebDriver.FindElement(By.LinkText("Administration Portal"))); headerElements.Add(WebDriver.FindElement(By.LinkText("Log in / Register"))); headerElements.Add(WebDriver.FindElement(By.LinkText("Log off"))); I was thinking for using a for loop to do this, would this be the best way. I'm trying to avoid writting methods like the one below for each link public void SelectCreateNewReferralLink() { var selectAboutUsLink = ( new WebDriverWait(WebDriver, new TimeSpan(50))).Until (ExpectedConditions.ElementExists(By.CssSelector("#main > a:nth-of-type(1)"))); selectCreateNewReferralLink.Click(); } I'm using C#, with WebDriver attempting to write this Any Help would be great Thanks Chris

    Read the article

  • looping problem while appending data to existing text file

    - by Manu
    try { stmt = conn.createStatement(); stmt1 = conn.createStatement(); stmt2 = conn.createStatement(); rs = stmt.executeQuery("select cust from trip1"); rs1 = stmt1.executeQuery("select cust from trip2"); rs2 = stmt2.executeQuery("select cust from trip3"); File f = new File(strFileGenLoc); OutputStream os = (OutputStream)new FileOutputStream(f,true); String encoding = "UTF8"; OutputStreamWriter osw = new OutputStreamWriter(os, encoding); BufferedWriter bw = new BufferedWriter(osw); } while ( rs.next() ) { while(rs1.next()){ while(rs2.next()){ bw.write(rs.getString(1)==null? "":rs.getString(1)); bw.write("\t"); bw.write(rs1.getString(1)==null? "":rs1.getString(1)); bw.write("\t"); bw.write(rs2.getString(1)==null? "":rs2.getString(1)); bw.write("\t"); bw.newLine(); } } } Above code working fine. My problem is 1. "rs" resultset contains one record in the table 2. "rs1" resultset contains 5 record in the table 3. "rs2" resultset contains 5 record in the table "rs" data is getting recursive. while writing to the same text file , the output i am getting like 1 2 3 1 12 21 1 23 25 1 10 5 1 8 54 but i need output like below 1 2 3 12 21 23 25 10 5 8 54 What things i need to change in my code.. Please advice

    Read the article

  • looping through an object (tree)

    - by Val
    Is there a way (in jquery or javascript) to loop through each object and it's children and gandchildren and so on. if so... can i also read their name? example foo :{ bar:'', child:{ grand:{ greatgrand: { //and so on } } } } so the loop should do something like this... loop start if(nameof == 'child'){ //do something } if(nameof == 'bar'){ //do something } if(nameof =='grand'){ //do something } loop end I know this is stupid code but i tried to make it understandable :) btw this is for a jquery UI, as i am clueless how to go on about this. thanks

    Read the article

  • ajax call is looping indefinitely

    - by zurna
    I am pulling categories from an xml file. I only have 5 categories but the code below keeps pulling categories indifitely! Weird thing, I dont even have a loop in the xml function. Test link: http://www.refinethetaste.com/FLPM/ $.ajax({ dataType: "xml", url: "/FLPM/content/home/index.cs.asp?Process=ViewVCategories", success: function(xml) { $(xml).find('row').each(function(){ var id = $(this).attr('id'); var CategoryName = $(this).find('CategoryName'); $("<div class='tab fleft'><a href='http://www.refinethetaste.com/FLPM/content/home/index.cs.asp?Process=ViewVideos&CATEGORYID="+ id +"'>"+ CategoryName.text() + "</a></div>").appendTo("#VCategories"); CategoryName.find("div.row-title .red").tabs("div.panes > div"); }); } });

    Read the article

  • While using ConcurrentQueue, trying to dequeue while looping through in parallel

    - by James Black
    I am using the parallel data structures in my .NET 4 application and I have a ConcurrentQueue that gets added to while I am processing through it. I want to do something like: personqueue.AsParallel().WithDegreeOfParallelism(20).ForAll(i => ... ); as I make database calls to save the data, so I am limiting the number of concurrent threads. But, I expect that the ForAll isn't going to dequeue, and I am concerned about just doing ForAll(i => { personqueue.personqueue.TryDequeue(...); ... }); as there is no guarantee that I am popping off the correct one. So, how can I iterate through the collection and dequeue, in a parallel fashion. Or, would it be better to use PLINQ to do this processing, in parallel?

    Read the article

  • Duplicate ID/indexes and looping

    - by Justin Alexander
    I realize having two elements in the same html doc with the same ID is wrong, bad, immoral, and will lead to global warming. But... I'm trying to write an XSS widgit, so I really have no control over the quality of the parent web page. I loop through document.images to retrieve a list of images on the page. I perform an action on each one. for(img in document.images){ ... } i've also tried for(var i=0;i<document.images.length;i++){ ... } in both cases it allows me to loop through all of the elements, BUT when trying trying to reference an object with a duplicate ID, I always get the first (in order of the html). When using debugger in IE8 i'm able to see that both elements ARE listed, but that they both have the same index (in IE the index of the document.images is either sequential or matches the image ID) Does anyone have a better solution?

    Read the article

  • Looping on a closed range

    - by AProgrammer
    How would you fix this code? template <typename T> void closed_range(T begin, T end) { for (T i = begin; i <= end; ++i) { // do something } } T is constrained to be an integer type, can be the wider of such types and can be signed or unsigned begin can be numeric_limits<T>::min() end can be numeric_limits<T>::max() (in which case ++i will overflow in the above code) I've several ways, but none I really like.

    Read the article

  • Looping through with double variables

    - by Luke
    I have two arrays with two sets of values in ($a[] and $b[]) I want to do something like the following: $a[0] - $b[0] $a[0] - $b[1] $a[1] - $b[0] $a[1] - $b[1] This will continue until the arrays reach the end. So i want a hyphen to seperate the two arrays, with the first array staying the same until the second array has looped through. I am trying to get this in a dropdown with option value. How could i achieve this? I never tried doing any loops with two varaibles like that before, I literally have no idea at all! Thankyou

    Read the article

  • ASP.net looping through controls in a table

    - by c11ada
    hey all, i have a table which contains a bunch of dynamically created radio button lists, im trying to write code which will loop through each one of the radio button list and get the text value of the selected item. i have the following code foreach ( Control ctrl in Table1.Controls) { if (ctrl is RadioButtonList) { //get the text value of the selected radio button } } but i am stuck on how i can get the value of the selected item for that given control.

    Read the article

  • PHP - Drilling down Data and Looping with Loops

    - by stogdilla
    I'm currently having difficulty finding a way of making my loops work. I have a table of data with 15 minute values. I need the data to pull up in a few different increments $filters=Array('Yrs','Qtr','Day','60','30','15'); I think I have a way of finding out what I need to be able to drill down to but the issue I'm having is after the first loop to cycle through all the Outter most values (ex: the user says they want to display by Hours, each hour should be able to have a "+" that will then add a new div to display the half hour data, then each half hour data have a "+" to display the 15 minute data upon request. Now I can just program the number of outputs for each value (6 different outputs) just in-case... but isn't there a way I can make it do the drill down for each one in a loop? so I only have to code one output once and have it just check if there are any more intervals after it and check for those? I'm sure I'm just overlooking some very simple way of doing this but my brain isn't being clever today. Sorry in advance if this is a simple solution. I guess the best way I could think of it as a reply on a form. How you would check to see if it's a reply of a reply, and then if that reply has any replys...etc for output. Can anyone help or at least point me in the right direction? Or am I stuck coding each possible check? Thanks in advance!

    Read the article

< Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >