martin2k

ForumsVB6GamesSoftwareDirectoryHTMLArticlesBlogContact

How do I create a program, which draws asterisks (*), one on the next line from the number on the last?


 

Home

Read and add posts to the Visual Basic 6.0 Forums

Download some of my programs and OCXs

Read the Tips here

The old style forum is still available here

Contact


 

Question

From: rustpr0of
Date: Saturday 21 March 2009 2:35 AM
Subject: help me with this program please..
Question: i need to do a program like showing like this: it has to be a 4 buttons anmed draw A, draw B, draw C, draw D. when button A is pressed it has to be like this
*
**
***
****
*****
******
*******
when button B is pressed it has to show this one
*******
******
*****
****
***
**
*
when button C is pressed it has to show this one
       *
      **
     ***
    ****
   *****
  ******
 *******
and last is when button D is pressed it will show this
*******
 ******
  *****
   ****
    ***
     **
      *
and there is also a STOP button for terminating the program.. please help me i need it soon.. thanks! and i love your site..

Firstly, create 4 buttons - Command1 to Command4 and name them "draw A" to "draw D".

Then copy and paste the following code:

Sub displayasterisks(drawmode As Integer, firstchar As String, secondchar As String)
Dim i As Integer, m As String 'm - message for msgbox

For i = 1 To 7
    If drawmode = 0 Then
        m = m & String(i, firstchar) & String(8 - i, secondchar)
    Else
        m = m & String(8 - i, firstchar) & String(i, secondchar)
End If

    m = m & vbCrLf
Next i

MsgBox m
End Sub


Private Sub Command1_Click() 'draw A
displayasterisks 0, "*", " "
End Sub


Private Sub Command2_Click() 'draw B
displayasterisks 1, "*", " "
End Sub


Private Sub Command3_Click() 'draw C
displayasterisks 1, " ", "*"
End Sub


Private Sub Command4_Click() 'draw D
displayasterisks 0, " ", "*"
End Sub

The 'STOP' button could have the code 'Unload Me' to close the program.

I hope this helps.


blog comments powered by Disqus
Martin Allen 1999 - 2011.  Last updated Saturday 13 August 2011 12:05:24 AM +0100.