473,480 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

I need help Looping Code in Visual Basic

1 New Member
Hey guys, I'm a VB noob sorry.... but I am making a simple friend adder for a social networking site called Teenspot.
Right now, when i click a button it will add the username that is on the listbox and add that person. What i am trying to do is make it automatically go down the list and add all of the usernames. To do that I just need to figure out how to correctly loop this code below

Expand|Select|Wrap|Line Numbers
  1. Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
  2.  
  3.         WebBrowser1.Navigate("www.teenspot.com/profiles/" & ListBox1.SelectedItem & "/add")
  4.         ListBox1.SelectedIndex = ListBox1.SelectedIndex + 5
  5.  
  6.         ' This is the "sleep" function.
  7.         ' This makes your webbrowser finish loading before new action.
  8.  
  9.  
  10.         Do Until WebBrowser1.ReadyState = WebBrowserReadyState.Complete And WebBrowser1.IsBusy = False
  11.             Application.DoEvents()
  12.         Loop
  13.  
  14.         WebBrowser1.Document.GetElementById("confirm").InvokeMember("click")
  15.  
  16.  
  17.         Try
  18.         Catch ex As Exception
  19.             ' Generates a messegebox with the error.
  20.             MsgBox(ex.Message, MsgBoxStyle.Critical, "Error")
  21.  
  22.         End Try
  23.  
  24.     End Sub
I have tried all kinds of ways to loop it but the problem i am having is that it just goes to the "add this person" page and it doesn't actually click yes to confirm the add. It skips the second part of the code. If someone could please help me that would be great.
Oct 30 '12 #1
1 1339
IronRazer
83 New Member
Hello cheesenips,
I see what the problem is. I had the same problem in my internet radio recorder program. I am sure you have noticed that when you open a website in IE that the page loads some stuff and then stops and starts a few times before the page is finished loading. The first time your WebBrowser1 stops it tells your Do Until loop that it has finished loading. Now it moves to the next command which is to click the button before WebBrowser1 is really finished loading the page.

I am not a member of the website this is being used on so i need to know the following before i can give a good example. I need to know if after the button on the website is clicked does it redirect you to another page on the site or does it stay on the same page ? If it stays on the same page does it take a few seconds for the new name to register before you can continue ?
Jan 20 '13 #2

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

Similar topics

2
2089
by: janice_2k | last post by:
Dear Sir/Mdm, I am writing this on behalf of my company. We bought the Visual Studio .NET Enterprise version but currently we need to use Visual Basic 6 for a small development. We are not able to...
2
12799
by: Ermi | last post by:
Hi, i have this problem.... From a visual basic application I must replace the value contained in a column with another one....for example Field1 ------ Alfa Beta Gamma
3
7053
by: Jay Patel | last post by:
Hello, I need to write visual basic.net code to interface with a Mettler Toledo Shipping Scale that interfaces with a PC via USB or a serial port. I have seen example code on how to communicate...
16
1437
by: Jesse Liberty | last post by:
I am writing a new book on Visual Basic 2005, targeted at VB6 programmers, and to some degree VB.NET 1.x programmers. I'd like to sign up a (limited) number of volunteers to read the book and...
8
1108
by: Raymond Lang | last post by:
I have an unusual situation in my facility. I need to install Visual Basic ..NET onto a user's system, however per corporate policy, we cannot install the IIS services or FrontPage Extensions onto...
7
1839
by: gerryLowry::Ability Business Computer Services {KC | last post by:
"Getting Back Your Visual Basic 6.0 Goodies" by Billy Hollis, 2003-5-14, states: "Getting a Forms Collection Visual Basic 6.0 developers are often fond of looping through the currently loaded...
0
888
by: Alex Pavluck | last post by:
Hello. I have always wanted to learn how to write programs as a hobby and Visual Basic 2005 Express seems like the perfect platform. Can someone who is more experience let me know if this is a...
2
4505
by: londonblokde | last post by:
Hello, If I want to learn VBA should I start by learning Visual Basic? I have no background in coding, but I need to learn VBA. So what is the best way to learn it; do I need to learn Visual Basic...
4
3061
by: Chris Asaipillai | last post by:
Hi there My compay has a number of Visual Basic 6 applications which are front endeed onto either SQL Server or Microsoft Access databases. Now we are in process of planning to re-write these...
0
1205
by: shangardezi | last post by:
hi im a beginner with visual basic. I was wondering can someone tell me how i can somehow do a thing that when someone presses ok on the LOGIN FORM, the username and password is sent to my email. im...
0
6904
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7076
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
6873
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5321
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,...
1
4767
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4471
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
2976
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1294
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
558
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.