Print Pyramid In VB.Net using For Loop

Need to print a Pyramid in VB.Net using For Loop

Page 1 of 1

4 Replies - 18250 Views - Last Post: 06 November 2008 - 12:09 AM Rate Topic: -----

#1 itchock  Icon User is offline

  • New D.I.C Head

Reputation: 1
  • View blog
  • Posts: 1
  • Joined: 28-July 07

Print Pyramid In VB.Net using For Loop

Post icon  Posted 28 July 2007 - 03:56 AM

Hi,

I like to print a pyramid with character * as below using For Loop in VB.Net.

*
***
*****
*******
*********
***********

Any help will be appreciated.

Thanks,
V.Chock.
Is This A Good Question/Topic? 1

Replies To: Print Pyramid In VB.Net using For Loop

#2 m2s87  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 21
  • View blog
  • Posts: 390
  • Joined: 28-November 06

Re: Print Pyramid In VB.Net using For Loop

Posted 28 July 2007 - 09:11 AM

You really should read background, part that says :
We Will Now Do Your Homework!
You Must Show Us Your Code.


To write in console you can use
Console.Write("text to write")

To crate a linefeed you can use
Console.WriteLine()
Console.Write(chr(13))
Console.Write(vbCrLf)

To declare a variable what scope is limited with a loop within it is declared as a parameter, that increases by 1 each time it is smaller then needed_value, the loop and declarations would look like:
		Dim needed_value As Int32 = 10
		For i As Int32 = 0 To needed_value
			'some code blocks that use i value
		Next i

You can look here, if you really can not solve it on your own, and translate it to VB.NET.
Was This Post Helpful? 0
  • +
  • -

#3 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1642
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Print Pyramid In VB.Net using For Loop

Posted 14 September 2007 - 10:36 AM

View Postaclc_dau, on 14 Sep, 2007 - 06:05 AM, said:

MOD EDIT: Content removed until memeber shows some effort per forum rules ~ jayman9


We don't just give people the code they're looking for, we don't do their homework for them so please don't do it either :)
Was This Post Helpful? 0
  • +
  • -

#4 transmoifer  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 05-November 08

Re: Print Pyramid In VB.Net using For Loop

Posted 05 November 2008 - 10:55 PM

View PostPsychoCoder, on 14 Sep, 2007 - 09:36 AM, said:

View Postaclc_dau, on 14 Sep, 2007 - 06:05 AM, said:

MOD EDIT: Content removed until memeber shows some effort per forum rules ~ jayman9


We don't just give people the code they're looking for, we don't do their homework for them so please don't do it either :)

Okay I got most of it done, but I don't know how I can keep adding a character without typing it in (Me.lbldisplay.Text = myChar & vbNewLine & myChar & myChar & vbNewLine, etc. My goal is to have seven rows without having to literally write it out.
Here is my code
"Private Sub btncreatep_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btncreatep.Click


Dim myChar As String = txtinput.Text
Dim strlen As Integer
strlen = myChar.Length
Dim my2Char As String = myChar
Dim MyPry As Integer = 7


If strlen = 1 Then

For i As Integer = 1 To MyPry Step 1
Me.lbldisplay.Text = (myChar - i + 1) + my2Char + vbNewLine

Next i
Else
Me.lbldisplay.Text = "Type only one Character"
End If


End Sub"
Was This Post Helpful? 0
  • +
  • -

#5 PsychoCoder  Icon User is offline

  • Google.Sucks.Init(true);
  • member icon

Reputation: 1642
  • View blog
  • Posts: 19,853
  • Joined: 26-July 07

Re: Print Pyramid In VB.Net using For Loop

Posted 06 November 2008 - 12:09 AM

Moved to VB.NET :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1