Click here to Skip to main content
15,896,500 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Its been a week now..
Can somebody please guide me how to make a reverse pyramid in vb.net??Hell of task to me..Working for a week as i am new in it .. :( Please advice??
it should be like this.Having spaces at both right and left to decrements (-) means spaces..Tried using loops and i know it can be done through it.. but to no use..its urgent :( please provide me for the vb.net..thanks and highly appreciated

**********
-********-
--*****--
--****--
---**---
----*--


[Edit] Code added from comment

VB
a = 1
For a = 5 To 1 Step -1
   b = 1
   For b = 1 To 6 - a
      Response.Write(" ")
   Next b
   c = 1
   For c = 1 To a
      Response.Write(" * ")
   Next c
   Response.Write("</br>")
Next a

I have used this..but its not giving me space on the right side...

[/Edit]
Posted
Updated 6-Nov-15 6:12am
v4
Comments
Member 12119549 6-Nov-15 9:15am    
No answer...Please can anybody there to help :(
Member 12119549 6-Nov-15 9:30am    
Anyoneeeeeeeeeee.???????
AnvilRanger 6-Nov-15 9:39am    
Begging every 15 minutes will not get you an answer. This is nothing but spam and everyone here hates that.

Now to your question you need to show us what you have done. If you have spent a week surely you have something to show.
Member 12119549 6-Nov-15 10:13am    
a = 1
For a = 5 To 1 Step -1
b = 1
For b = 1 To 6 - a
Response.Write(" ")
Next b
c = 1
For c = 1 To a
Response.Write(" * ")
Next c
Response.Write("</br>")
Next a

I have used this..but its not giving me space on the right side...
Member 12119549 6-Nov-15 11:57am    
Dim i, j, k As Integer
i = 1
For i = 5 To 1 Step -1
j = 1
For j = 1 To (6 - i)
Response.Write("p")

Next j
k = 1
For k = 1 To i
Response.Write(" * ")
Next k
Response.Write("</br>")
Next i

End Sub
One more thing when i add p i get the required result..
p * * * * *
pp * * * *
ppp * * *
pppp * *
ppppp *
but these p need to be pissed off :(

1 solution

We do not do your homework: it is set for a reason. It is there so that you think about what you have been told, and try to understand it. It is also there so that your tutor can identify areas where you are weak, and focus more attention on remedial action.

Try it yourself, you may find it is not as difficult as you think!

If you meet a specific problem, then please ask about that and we will do our best to help. But we aren't going to do it all for you!

But I'll give you a hint: You need two loops, one inside the other.
Start by getting the outer loop to print the number of lines you need (blank newlines),
and print the number of "stars" you want on each line as well.
When you have that working, replace the "stars count" print with a second loop to print the right number of stars.

This is basic stuff: breaking down the task into smaller, easier-to-do jobs and then doing them.
 
Share this answer
 
Comments
Member 12119549 6-Nov-15 10:17am    
Thanks ..let me try it
Member 12119549 6-Nov-15 10:56am    
Dim i As Integer

For i = 1 To 5
Response.Write("*")

Next
i += 1
printed stars in the first row.. now what can i proceed..plz help..know its childish but need some help..i am not asking for solution,.need clues
OriginalGriff 6-Nov-15 10:59am    
Read what I said again: start with the outer loop, then work on the inner.
Member 12119549 6-Nov-15 11:06am    
Your responce is very much appriciated sir..added a spark in me..just need the spaces..working on it..
Member 12119549 6-Nov-15 11:04am    
Dim i, j As Integer

For i = 1 To 5
For j = 1 To 5
Response.Write("*")
Next
Response.Write("</br>")

Next
i += 1

Yesss ..........!!! succedded in adding a staight liness..now just space remain..

*****
*****
*****
*****
*****
how to add it..?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900