473,396 Members | 1,804 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,396 software developers and data experts.

For some reason, my program is running in a loop and the condition is being ignored.

I am trying to make a view bot. Just for recreational/personal use. The problem is I am trying to make it so it will only open 20 windows at a time. It won't work for some reason. I also want it to wait 2000 milliseconds before closing the process it generates and go into a loop. I have co1unt as an integer. Anyone help please?
Expand|Select|Wrap|Line Numbers
  1. Dim Co1unt As Integer = 0
  2. Public Sub Refreshlist()
  3.     Dim p As Process, co1unt As Integer, MyProgram As String = "iexplore"
  4.     For Each p In Process.GetProcesses
  5.         If p.ProcessName = MyProgram Then
  6.             co1unt = co1unt + 1
  7.             TextBox1.Text = co1unt
  8.         End If
  9.     Next
  10. End Sub
  11.  
  12. Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  13.     Refreshlist()
  14.     Do
  15.         Refreshlist()
  16.         If Co1unt < 20 Then
  17.             Dim webAddress As String = ""
  18.             Dim p1 As Process = Process.Start(webAddress)
  19.             System.Threading.Thread.Sleep(2000)
  20.             p1.Kill()
  21.         End If
  22.     Loop
  23.  
  24. End Sub
Apr 1 '13 #1
2 1214
Rabbit
12,516 Expert Mod 8TB
Are you sure the process name is "iexplore"? On my task manager, it shows "iexplore.exe *32"
Apr 1 '13 #2
Killer42
8,435 Expert 8TB
Actually you have a simple variable-scope bug, very easy to do, and very easy to miss.

Variable Co1unt is defined (with different capitalisation, which VB doesn't really care about) both at the module level and within the sub Refreshlist. The variable you're adding 1 to only exists for the moment that you're in that sub (from line 3 to line 10).

Thus the module-level variable doesn't change, and so will never reach 20.
Apr 4 '13 #3

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

Similar topics

3
by: NetMasker | last post by:
Using VB.NET 2003 I want to keep a program running and waiting for users' input without using a Form that loads at program execution. Can I do it using just one Module or what? Is this possible or...
2
by: Razor | last post by:
How can I call a sub and keep the main program running while it works?
8
by: Chris Thunell | last post by:
I have created a VB.net windows forms application. If I have the program running and then I mistakenly click on my desktop icon again, I get a second instance of the program running. Is there...
1
by: Chris | last post by:
I've created an aspx page that should time out every time it is executed, yet it never does. It seems as though the value of Server.ScriptTimeout is just being ignored by asp.net - I've also set...
1
by: David Hearn | last post by:
I am trying to generate a short text based email and using VBCrlf to break the lines. The problem is that they are being ignored after about the third or fourth line down into the email. I have...
1
by: meltedown | last post by:
https://newglobalsoaps.com/catalog/index.php?pline=7857 There is a menu on the left- its floated to the left. the div with id all is supossed to have a margin-left but its being ignored. ...
0
by: Timothy Greaves | last post by:
Hi I have a PC with XP SP2 and IIS 5.1 installed. I also have VS 2002 and Interdev 6.0 installed. I am having problems getting the system to perform JIT debugging on ASP pages. I have enabled...
14
by: William LaMartin | last post by:
If I have a Windows application with no form--only a module that starts with sub main and which has a system timer, in the elapsed event of which I want to run some code, how can I keep this...
6
by: maya | last post by:
<tabletag is being ignored here.. why is this.. <div id="img1"> <script type="text/javascript" language="JavaScript"> var cw = document.body.clientWidth; var ch =...
4
BeemerBiker
by: BeemerBiker | last post by:
I am using veranda and x-small fonts everywhere. I even specified that font in "edit row style" and when that didnt work, anywhere I found an empty style. However, it is being ignored and a textbox...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.