VB.NET School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 308,420 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 3,378 people online right now. Registration is fast and FREE... Join Now!




rewrite this program using while_loop ? i dont understand? pls help, a

 

rewrite this program using while_loop ? i dont understand? pls help, a

Satish_Flatline

18 Aug, 2009 - 09:34 PM
Post #1

New D.I.C Head
*

Joined: 18 Aug, 2009
Posts: 3


My Contributions
CODE

Module Module1

    Sub Main()
      Dim product As Integer = 3
      Do Until product > 100
         Console.Write(product & " ")
         product = product * 3
      Loop
      Console.WriteLine()
      Console.WriteLine("First power of 3 " & _
" Larger than 100 is " & product)

    End Sub
End Module


** Edit ** code.gif

User is offlineProfile CardPM
+Quote Post

 
Reply to this topicStart new topic
Replies(1 - 8)

NoBrain

RE: Rewrite This Program Using While_loop ? I Dont Understand? Pls Help, A

18 Aug, 2009 - 10:31 PM
Post #2

D.I.C Lover
Group Icon

Joined: 25 Mar, 2009
Posts: 1,225



Thanked: 39 times
Dream Kudos: 125
My Contributions
so what is the problem ?
User is online!Profile CardPM
+Quote Post

Satish_Flatline

RE: Rewrite This Program Using While_loop ? I Dont Understand? Pls Help, A

18 Aug, 2009 - 10:36 PM
Post #3

New D.I.C Head
*

Joined: 18 Aug, 2009
Posts: 3


My Contributions
QUOTE(NoBrain @ 18 Aug, 2009 - 10:31 PM) *

so what is the problem ?



i dont understand how to do ?

they said i have to rewrite it using while loop?
User is offlineProfile CardPM
+Quote Post

NoBrain

RE: Rewrite This Program Using While_loop ? I Dont Understand? Pls Help, A

18 Aug, 2009 - 10:41 PM
Post #4

D.I.C Lover
Group Icon

Joined: 25 Mar, 2009
Posts: 1,225



Thanked: 39 times
Dream Kudos: 125
My Contributions
ok so yoou want to change this

CODE

      Do Until product > 100
         Console.Write(product & " ")
         product = product * 3
      Loop


to this

CODE

      Do While product > 100
         Console.Write(product & " ")
         product = product * 3
      Loop


but ... it will never go out of this cycle or will never go in depend on what value you give on "product"

This post has been edited by NoBrain: 18 Aug, 2009 - 10:42 PM
User is online!Profile CardPM
+Quote Post

zhanfeng

RE: Rewrite This Program Using While_loop ? I Dont Understand? Pls Help, A

19 Aug, 2009 - 08:28 AM
Post #5

D.I.C Head
**

Joined: 9 Nov, 2008
Posts: 65



Thanked: 5 times
My Contributions
I think you have made a mistake, NoBrain. The parameter for the do while loop should be
CODE
product <= 100
like below:

CODE

Do While product <= 100
      Console.Write(product & " ")
      product = product * 3
Loop

User is offlineProfile CardPM
+Quote Post

PsychoCoder

RE: Rewrite This Program Using While_loop ? I Dont Understand? Pls Help, A

19 Aug, 2009 - 08:43 AM
Post #6

I Code, Therefore I am
Group Icon

Joined: 26 Jul, 2007
Posts: 15,001



Thanked: 522 times
Dream Kudos: 11700
Expert In: VB, VB.Net, C#, SQL, ASP, ASP.Net, Web Development, HTML, CSS, Win32 API, Javascript, mySQL, J#, Boo.Net, jQuery

My Contributions
Moved to VB.NET (I don't remember VB6 having console applications) smile.gif
User is offlineProfile CardPM
+Quote Post

mark.bottomley

RE: Rewrite This Program Using While_loop ? I Dont Understand? Pls Help, A

19 Aug, 2009 - 08:56 AM
Post #7

D.I.C Addict
****

Joined: 22 Apr, 2009
Posts: 885



Thanked: 149 times
My Contributions
I would also add a Console.Readline() at the bottom so it doesn't just flash by and close the console window before you can see 243 (the answer). The program does work currently, just takes very fast eyes!

While loop options are:
Do While i < 100
...
End While

Do
...
Loop While i < 100

Do
...
Loop Until i >= 100
User is online!Profile CardPM
+Quote Post

AdamSpeight2008

RE: Rewrite This Program Using While_loop ? I Dont Understand? Pls Help, A

19 Aug, 2009 - 09:47 AM
Post #8

The Bandido Coder
Group Icon

Joined: 29 May, 2008
Posts: 2,744



Thanked: 160 times
Dream Kudos: 3925
Expert In: vb.net, LINQ

My Contributions
QUOTE(PsychoCoder @ 19 Aug, 2009 - 04:43 PM) *

Moved to VB.NET (I don't remember VB6 having console applications) smile.gif

It was possible just not as easily as you can in vb.net

Equivalent Loops Tutorial

This post has been edited by AdamSpeight2008: 19 Aug, 2009 - 09:49 AM
User is online!Profile CardPM
+Quote Post

Satish_Flatline

RE: Rewrite This Program Using While_loop ? I Dont Understand? Pls Help, A

4 Oct, 2009 - 02:49 AM
Post #9

New D.I.C Head
*

Joined: 18 Aug, 2009
Posts: 3


My Contributions
thanks for the help folks, appreciate it very much.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/24/09 01:06PM

Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month