By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,985 Members | 1,885 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,985 IT Pros & Developers. It's quick & easy.

how to pass objects to a array in another form?

P: 1

This is all in 2005

I am trying to make a programme that will take in a completed survey and then store that survery object within an array.

Currently i know my Surveyclass works and that my array works but when i try to use a function to pass then array from the main form to the survey input form it doesnt seem to store anything in the array.

This is the code for my main form that opens apon running and is where i create the array


Public Class MainForm
Private Survey(20) As SurveyClass
'' Private lastused As Integer = 0

Private Sub MainForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ClearToolStripMenuItem1.Visible = False
End Sub

Public Function getSurveyArray() As SurveyClass
Survey(0) = New SurveyClass()

Return Survey(0)
End Function
End Class


and this is the code on my addSurveyForm that pops up when you select to enter in a new survey

Public Class AddSurveyForm


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If RadioButton1.Checked Then
MainForm.getSurveyArray.questionString1 = "Yes"

MainForm.getSurveyArray.questionString1 = "No"
End If
Label11.Text = MainForm.getSurveyArray.questionString1
End Sub

End Class


Im aware that currently the code isnt that well formed and so on but im mainly intrested in getting it to just run alittle

This is homework set by my school and i have asked my teacher in class but she isnt in class alot of the time, so im looking for alittle help elsewhere.
Sep 6 '07 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 1,295
maybe this other forum could help

or you can always create a module with a sub and a function:

Expand|Select|Wrap|Line Numbers
  1. dim arr1(1 to 10) as string
  2. sub InArr(byval i as integer, byval val as string)
  3. arr(i) = string
  4. end sub
  5. public function OutArr(byval i as integer)
  6. outarr = arr(i)
  7. end function
this way in any form you can always call the nth element with outarr(n) or you can always store a value in it with call inarr(n, "hello").
Sep 7 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.