Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old December 9th, 2012, 11:34 AM
hemihead_dave hemihead_dave is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 8 hemihead_dave User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 17 m 34 sec
Reputation Power: 0
Need Help with Code

I had to write a code that displays this
*****
*****
*****
I had to use the For...Next statements. The code works, except when I hit the start button to calculate it displays this
*****
*****
*****
If I hit it again it adds to it.
*****
*****
*****
*****
*****
*****
and it keeps going if I keep hitting the button. How can I stop it at the first calculation?

Here is the code.

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
For x As Integer = 1 To 3 Step 3
For y As Integer = 1 To 9 Step 2
asterisksLabel.Text = asterisksLabel.Text & "*"
Next y
asterisksLabel.Text = asterisksLabel.Text & ControlChars.NewLine
Next x
For x As Integer = 1 To 3 Step 2
For y As Integer = 1 To 9 Step 2
asterisksLabel.Text = asterisksLabel.Text & "*"
Next y
asterisksLabel.Text = asterisksLabel.Text & ControlChars.NewLine
Next x
End Sub

Reply With Quote
  #2  
Old December 9th, 2012, 07:32 PM
couttsj couttsj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2011
Posts: 168 couttsj User rank is Sergeant Major (2000 - 5000 Reputation Level)couttsj User rank is Sergeant Major (2000 - 5000 Reputation Level)couttsj User rank is Sergeant Major (2000 - 5000 Reputation Level)couttsj User rank is Sergeant Major (2000 - 5000 Reputation Level)couttsj User rank is Sergeant Major (2000 - 5000 Reputation Level)couttsj User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Days 17 h 48 m 49 sec
Reputation Power: 43
It is doing exactly what you told it to do. It is adding 3 sets of 5 asterisks to the existing text each time you click the command button. If you want to refresh the displayed text, you must clear the box first:
asterisksLabel.Text = ""

J.A. Coutts

Reply With Quote
  #3  
Old December 9th, 2012, 10:43 PM
hemihead_dave hemihead_dave is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2012
Posts: 8 hemihead_dave User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 17 m 34 sec
Reputation Power: 0
Thanks

I finally figured it out that I needed that before the code started. Thanks for the information

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Need Help with Code

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap