Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual 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 ASP Free Forums Sponsor:
  #1  
Old April 24th, 2005, 08:10 PM
Kudo_Shiho Kudo_Shiho is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Location: Hawaii
Posts: 12 Kudo_Shiho User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 2 m 52 sec
Reputation Power: 0
Unhappy help on coding

Hi, I need help on coding for VB.net.
This kind of goes with the looping question I had before but I wasn't sure if I should post it there or not so I put it here.
I have been working on this for a long time but something is wrong with it so it isn't working. But I have no clue as to what I did wrong so I was wondering if anyone could help me.
The first loop is supposed to count the number of even positive integers that are <= N and the second loop is supposed to sum the first N odd integers.
Thank you.
Code:
Private Sub btnCalculate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalculate.Click
   		Dim iPositiveIntegerN As Integer
   		Dim iEven As Integer
   		Dim iOdd As Integer
   		Dim iKount As Integer
   
   		iPositiveIntegerN = txtPositiveIntegerN.Text
   
   		iKount = 0
   		
   		Do Until iKount > 0
   			iEven = iPositiveIntegerN / 2
   			iKount = iKount + 1
   		Loop
   
   		lblEven.Text = iEven
   
   		iOdd = 3
   		iKount = 1
   
   		Do Until iKount > iPositiveIntegerN
   			iOdd = iOdd + iKount
   			iKount = iKount + 1
   		Loop
   
   		lblOdd.Text = iOdd
   
   		txtPositiveIntegerN.Focus()
   
   	End Sub

Reply With Quote
  #2  
Old April 25th, 2005, 12:53 AM
Kudo_Shiho Kudo_Shiho is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Location: Hawaii
Posts: 12 Kudo_Shiho User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 2 m 52 sec
Reputation Power: 0
I'm sorry if the title of the thread is confusing. I should have wrote "help" instead of "advice" Sorry.

Reply With Quote
  #3  
Old April 25th, 2005, 07:14 AM
hithere's Avatar
hithere hithere is offline
Learner
ASP Free Newbie (0 - 499 posts)
 
Join Date: Nov 2004
Location: India
Posts: 450 hithere User rank is Sergeant (500 - 2000 Reputation Level)hithere User rank is Sergeant (500 - 2000 Reputation Level)hithere User rank is Sergeant (500 - 2000 Reputation Level)hithere User rank is Sergeant (500 - 2000 Reputation Level)hithere User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 5 Days 12 h 13 m 21 sec
Reputation Power: 18
This code is in VB but u can convert into vb.net coz i dont know .net

N = Val(Text1.Text)
ecount = 0
sumodd = 0
For i = 1 To N
a = i Mod 2
If a = 0 Then
ecount = ecount + 1
Else
sumodd = sumodd + i
End If
Next
MsgBox "Total even numbers : " & ecount
MsgBox "Sum of Odd numbers : " & sumodd

Reply With Quote
  #4  
Old April 26th, 2005, 02:17 AM
Kudo_Shiho Kudo_Shiho is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Mar 2005
Location: Hawaii
Posts: 12 Kudo_Shiho User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 12 h 2 m 52 sec
Reputation Power: 0
Thank you very much everyone.
I finally figured out how to write it.
I realized it was something really easy that I didn't notice, once again Thank you again.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > advice on coding


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 | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway
Stay green...Green IT