Need help with an array
Need help with an array
Need help with an array
Need help with an array
Need help with an array
Need help with an array Need help with an array Need help with an array Need help with an array Need help with an array Need help with an array Need help with an array Need help with an array
Need help with an array Need help with an array
Need help with an array
Go Back  Xtreme Visual Basic Talk > > > Need help with an array


Reply
 
Thread Tools Display Modes
  #1  
Old 05-17-2010, 04:00 PM
karen_the_lost karen_the_lost is offline
Newcomer
 
Join Date: May 2010
Posts: 4
Question Need help with an array


I have a pair of parallel string arrays that I am using to store the name of a room and the description of a room for a game I am writing.
The way the game works is thus:
It is a picturebox on the main form, and this picturebox contains a floorplan for a hospital(it's a hokey horror survival silenthill ripoff, but its just to demonstrate my coding power for a class). The project as such requires all the information to be read into a pair of arrays.
I've got that down easy easy, but the problem is, when you click a room on this floorplan, it opens a new form.
What I'm trying to do here is to pull the name of the room from that array and load it to the form.caption, and then the description to a multiline, scrollbar enabled textbox(again not an issue). The literal ONLY problem I am having is that my array isnt present on the new form.
I just dont know how to call it or pull it or what have you from the master form.
(the forms are not an array of forms, i dunno if that affects anything)
Reply With Quote
  #2  
Old 05-17-2010, 07:19 PM
ZaCkOX's Avatar
ZaCkOX ZaCkOX is offline
Contributor
 
Join Date: May 2006
Location: CA
Posts: 645
Default Module time?

Why not use a public array? OR... use a few strings in a module and declare them public, set them before leaving a form and entering another. Then label.Caption = that public variable.

Note: Don't declare a public array in your form. Problems with that, just use a module.
__________________
ZaCkO ... Who is your attitude?
Reply With Quote
  #3  
Old 05-18-2010, 01:13 AM
vb5prgrmrNeed help with an array vb5prgrmr is offline
Senior Contributor

* Expert *
 
Join Date: Mar 2009
Posts: 1,087
Default

>Note: Don't declare a public array in your form. Problems with that, just use a module.

What problems?
Code:
Option Explicit
Public ArrayNumber As Integer
Public MyArray(1 To 10) As String

Private Sub Form_Load()
'read strings into array
'but for demo, we set one...
MyArray(5) = "This is a test."
End Sub

Private Sub Picture1_Click()
ArrayNumber = 5
Form2.Show
End Sub
then in form2...

Code:
Private Sub Form_Load()
Me.Caption = Form1.MyArray(Form1.ArrayNumber)
End Sub


Good Luck
__________________
Just because I'm an expert does not mean I know it all and just because I know it all does not mean I'm an expert
Reply With Quote
  #4  
Old 05-18-2010, 02:30 AM
ZaCkOX's Avatar
ZaCkOX ZaCkOX is offline
Contributor
 
Join Date: May 2006
Location: CA
Posts: 645
Default Sorry...

I meant problems could arise. What if you need to close the form? You could use a public array in a form. Maybe it's more of my opinion I just thinks it's better in a module, anything public is organized in one spot. But really doesn't matter as long as the individual knows what they are doing.
__________________
ZaCkO ... Who is your attitude?
Reply With Quote
  #5  
Old 05-18-2010, 07:44 AM
vb5prgrmrNeed help with an array vb5prgrmr is offline
Senior Contributor

* Expert *
 
Join Date: Mar 2009
Posts: 1,087
Default

Okay, gotcha, know what you mean and on that point I can agree....
__________________
Just because I'm an expert does not mean I know it all and just because I know it all does not mean I'm an expert
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Need help with an array
Need help with an array
Need help with an array Need help with an array
Need help with an array
Need help with an array
Need help with an array Need help with an array Need help with an array Need help with an array Need help with an array Need help with an array Need help with an array
Need help with an array
Need help with an array
 
Need help with an array
Need help with an array
 
-->