We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,610 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Asterisk Pattern Using Looping Statement

I just want to know how Can I display an asterisk pattern like

if the user selects on the combobox.additem = 1 then it will display

*
**
***
**
*

If user selects combobox.additem= 2 then

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

then so on and so forth until combobox.additem =2

Following were the codes that I have used...

Thank YOu

Dim x As Integer
Dim y As String


Private Sub cmdCreate_Click()
y = "*"
Wave = cboWave.Text

If Wave = "1" Then
x = 5
Do
Print y
x = x - 1
y = y + "*"
Loop Until x = 2

End If
End Sub
2
Contributors
3
Replies
6 Days
Discussion Span
2 Years Ago
Last Updated
5
Views
samurai14
Newbie Poster
3 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Try the following code. I have changed your if then to a select statement. When the "*" gets to 4, it counts back 1 at a time by removing the last "*" -

Option Explicit

Private Sub Command1_Click()

Dim x As Integer, z As Integer
Dim y As String, Wave As String

x = 5
z = 3
y = "*"
Wave = cboWave.Text

Select Case Wave

Case 1
    Do
    Print y
    x = x - 1
    y = y + "*"
    Loop Until x = 2
    
    Do
    Print y
    If y = vbNullString Then
        Exit Sub
            Else
        y = Left$(y, Len(y) - 1)
    End If
    Loop Until x = 0
End Select
End Sub

Just play around if user selects 2, 3, 4 etc from combobox.

AndreRet
Industrious Poster
4,706 posts since Jan 2008
Reputation Points: 391
Solved Threads: 481
Skill Endorsements: 20

thanks for the help

samurai14
Newbie Poster
3 posts since Mar 2010
Reputation Points: 10
Solved Threads: 0
Skill Endorsements: 0

Only a pleasure. If this solved your problem, please mark it as solved, thanks.

AndreRet
Industrious Poster
4,706 posts since Jan 2008
Reputation Points: 391
Solved Threads: 481
Skill Endorsements: 20

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.0646 seconds using 2.64MB