424,952 Members | 1,722 Online
Need help? Post your question and get tips & solutions from a community of 424,952 IT Pros & Developers. It's quick & easy.

# Help With Triangle Program!!!

 P: 2 I need help starting out this program, ANY HELP IS GREATLY APPRECIATED. I have to make a code up that a user inputs a number and the program makes lines with an asterisks. The first line will have one asterisk and the next line will have two and so on until it gets to the number entered making a triangular shape of asterisks. Thanks in advance for any help! It should come out like this if the user inputed number was for example 7 * ** *** **** ***** ****** ******* Apr 23 '07 #1
4 Replies

 Expert 5K+ P: 8,434 The experts on this site are more than happy to help you with your problems but they cannot do your assignment/program for you. Attempt the assignment/program yourself first and post questions regarding any difficulties you have or about a particular function of the code that you don't know how to achieve. Please read the Posting Guidelines and particularly the Coursework Posting Guidlines. Then when you are ready post a new question in this thread. MODERATOR Apr 24 '07 #2

 P: 2 I tried making this code but i need help getting it complete...something like this Expand|Select|Wrap|Line Numbers Dim i As Integer Dim n As Integer Dim j As Integer Dim lstDisplay As Integer i = 0 i = 0 While i < n     j = 0     j = 0     While j <= i         lstDisplay = ("*")         System.Math.Min(System.Threading.Interlocked.Increment(j), j - 1)     End While     lstDisplay = ("" & Microsoft.VisualBasic.Chr(10) & "")     System.Math.Min(System.Threading.Interlocked.Increment(i), i - 1) End While   Apr 24 '07 #3

 Expert 5K+ P: 8,434 System.Math.Min(System.Threading.Interlocked.Incre ment(j), j - 1) What the BLEEP does this do? (Don't worry about the space in "incre ment" - it's just some formatting thing that TheScripts is doing to the text). Phew! Interesting code. A couple of questions...Have you tried using a For loop rather than a While loop? They're much simpler. Have you worked with strings at all? Probably the simplest thing to do would be to start with an empty string each time 'round, and add asterisks onto it until you reach i. Apr 24 '07 #4

 100+ P: 103 if you are using VB6 you could use "String\$(N,C)" it will create a string of C N times (ie String\$(10,"*") would return "**********") if you use a for loop as Killer42 suggested then you could use the counter to supply the number argument. Apr 24 '07 #5