Meka][Meka Unstopable Posts: 700
| note: you may use this tutorial on other sites as long as u leave the author note -------------------------- Arrays -------------------------- Author: Meka][Meka -------------------------- http://www.meka-meka.com/ -------------------------- Hello welcome to another tut on passing data to a function, the easy way, you must have come across a time you have had to use a function passing alot of data such as this:
Code: | Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load TheFunction("Meka][Meka", "http://www.meka-meka.com/", "password", "misc info", "201") End Sub Private Sub TheFunction(ByVal username As String, ByVal userdesc As String, ByVal userpass As String, ByVal usertag As String, ByVal userage As Integer) MsgBox(username) MsgBox(userdesc) MsgBox(userpass) MsgBox(usertag) MsgBox(userage) 'whatever else here End Sub | well ther is an easier way, using an array, we need to create the array of strings
Code: | Dim info() As String = {"Meka][Meka", "http://www.meka-meka.com/", "password", "misc info", "201"} | do an easy loop for the msg boxes
Code: | Private Sub TheFunction(ByVal info() As String) For i As Integer = 0 To info.GetUpperBound(0) MsgBox(info(i)) Next 'whatever else here End Sub | then call the function
Code: | Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim info() As String = {"Meka][Meka", "http://www.meka-meka.com/", "password", "misc info", "201"} TheFunction(info) End Sub | voila, an easier and much better way of passing the data to the functioin
|