View Single Post
  #2 (permalink)  
Old 06-25-2007, 11:18 PM
ccoonen ccoonen is offline
PT Staff
Awards Showcase
Quality Tutorial Quality Tutorial Quality Tutorial Quality Tutorial 
Total Awards: 4
Join Date: Jun 2007
Location: Wisconsin
Posts: 317
iTrader: (0)
ccoonen is on a distinguished roadccoonen is on a distinguished roadccoonen is on a distinguished roadccoonen is on a distinguished road
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