![]() |
|
|
|
| ||||||
|
Welcome to the The ProgrammersTalk Community forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| Tags: |
![]() |
![]() | | LinkBack | Thread Tools | Display Modes | ![]() |
| |||
| [SOLVED] Can anybody help me with this Program in Visual Basic, please !!? Part #1: ASCII art has been around for quite some time. In the 60s and 70s, programmers of mainframe computers used the computers during downtime to generate posters and pictures. The task is to create a program which draws a simple shape-- triangle. * ** *** **** ***** **** *** ** * REQUIREMENTS: Use loop(s) to draw the shape. Print one character at the time. One character per loop iteration. Receive the size of the triangle from the the user through a texbox. ( Valid user input is 5,6,7,8 ) The number received will be the largest horizontal point in the triangle. The program should be able to create different sizes of triangles, based upon user input. Provide error cheking to make sure the user input is in the range of 5 to 8. Do not use any arrays in this program. Use modular program design. Use procedures and/or fuctions for all modules and incorporate "pass by reference" between modules. |
| |
| |||
| Here's a byref function i just made for yah Validates must be 5-8, passes integer byref, no arrays used, just iterations over a value.Code: Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
MsgBox(BuildTriangle(9))
End Sub
Public Function BuildTriangle(ByRef MaxAmt As Integer) As String
' Initial Counter for Inner Loop, and Iterators, and Return Value
Dim Counter As Integer = 0, _
X As Integer, _
Y As Integer, _
RetVal As String = ""
If (MaxAmt < 9) And (MaxAmt > 4) Then
' Build the incrementing portion of the triangle
For X = 1 To MaxAmt
Counter += 1
For Y = 1 To Counter
RetVal &= "*"
Next
RetVal &= vbCrLf
Next
' Build the decrementing portion of the triangle
For X = 1 To MaxAmt - 1
Counter -= 1
For Y = 1 To Counter
RetVal &= "*"
Next
RetVal &= vbCrLf
Next
Else
RetVal = "Please enter a value between 5 and 8"
End If
' Return the str
Return RetVal
End Function
End Class __________________ Day Cares | Golf Courses | Disc Golf Courses | Campgrounds | Ice Rinks | Paintball Fields | Dentists | Plastic Surgeons | Aging Jokes Catholic Churches | Lutheran Churches | Methodist Churches | Episcopal Churches | Clean Jokes |
![]() |
| Thread Tools | |
| Display Modes | |
| |