<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'declaring public array' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'declaring public array' posted on the 'Visual Basic' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Tue, 18 Jun 2013 20:22:50 -0700</pubDate>
    <lastBuildDate>Tue, 18 Jun 2013 20:22:50 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>declaring public array</title>
      <link>http://www.programmersheaven.com/mb/VBasic/287230/287230/declaring-public-array/</link>
      <description>Hi; &lt;br /&gt;
&lt;br /&gt;
  i search thru the forum but failed to find the solution that i want... &lt;br /&gt;
  i am using vb6, my problem is i would like to declare a public array with 2 dimension, but an error message prompted and tell me that it is not allowed to do so, so after searching the net i using the LET and GET method but i still not really know how to use it, can someone help? below is my code: &lt;br /&gt;
&lt;br /&gt;
**************************************************
*********************&lt;br /&gt;
in my class1: &lt;br /&gt;
&lt;br /&gt;
Private GraphicArr(1 To 2, 50) As String &lt;br /&gt;
&lt;br /&gt;
Public Property Get GArray(ShpType As Integer, ShpNo As Integer) As String &lt;br /&gt;
    GArray = GraphicArr(ShpType, ShpNo) &lt;br /&gt;
End Property &lt;br /&gt;
&lt;br /&gt;
Public Property Let GArray(ShpType As Integer, ShpNo As Integer, Value As String) &lt;br /&gt;
    GraphicArr(ShpType, ShpNo) = Value &lt;br /&gt;
End Property &lt;br /&gt;
&lt;br /&gt;
**************************************************
*********************&lt;br /&gt;
&lt;br /&gt;
  i would like to know in my main form, how can i set the value by calling the GArray and how do i call back to retrieve the value? &lt;br /&gt;
&lt;br /&gt;
really need your help, please...... &lt;br /&gt;
&lt;br /&gt;
Thanks :)&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/VBasic/287230/287230/declaring-public-array/</guid>
      <pubDate>Mon, 03 Jan 2005 20:48:32 -0700</pubDate>
      <category>Visual Basic</category>
    </item>
    <item>
      <title>Re: declaring public array</title>
      <link>http://www.programmersheaven.com/mb/VBasic/287230/287260/re-declaring-public-array/#287260</link>
      <description>&lt;strong&gt;&lt;span style="color: Red;"&gt;This message was edited by Genjuro at  2005-1-4 9:31:9&lt;/span&gt;&lt;/strong&gt;&lt;hr /&gt;&lt;br /&gt;
: Hi; &lt;br /&gt;
: &lt;br /&gt;
:   i search thru the forum but failed to find the solution that i want... &lt;br /&gt;
:   i am using vb6, my problem is i would like to declare a public array with 2 dimension, but an error message prompted and tell me that it is not allowed to do so, so after searching the net i using the LET and GET method but i still not really know how to use it, can someone help? below is my code: &lt;br /&gt;
: &lt;br /&gt;
: **************************************************
*********************&lt;br /&gt;
: in my class1: &lt;br /&gt;
: &lt;br /&gt;
: Private GraphicArr(1 To 2, 50) As String &lt;br /&gt;
: &lt;br /&gt;
: Public Property Get GArray(ShpType As Integer, ShpNo As Integer) As String &lt;br /&gt;
:     GArray = GraphicArr(ShpType, ShpNo) &lt;br /&gt;
: End Property &lt;br /&gt;
: &lt;br /&gt;
: Public Property Let GArray(ShpType As Integer, ShpNo As Integer, Value As String) &lt;br /&gt;
:     GraphicArr(ShpType, ShpNo) = Value &lt;br /&gt;
: End Property &lt;br /&gt;
: &lt;br /&gt;
: **************************************************
*********************&lt;br /&gt;
: &lt;br /&gt;
:   i would like to know in my main form, how can i set the value by calling the GArray and how do i call back to retrieve the value? &lt;br /&gt;
: &lt;br /&gt;
: really need your help, please...... &lt;br /&gt;
: &lt;br /&gt;
: Thanks :)&lt;br /&gt;
&lt;br /&gt;
I am assuming that code is written inside a "class module" ("class1" hints to that), in a standard EXE project.&lt;br /&gt;
&lt;br /&gt;
To use that array, first of all, you should declare your "class1" object, so put: &lt;br /&gt;
&lt;pre class="sourcecode"&gt;private GraphHelper as class1&lt;/pre&gt;&lt;br /&gt;
in your "global declarations" section of the form. &lt;br /&gt;
&lt;br /&gt;
Then you should instance it inside your Form_Load procedure: &lt;br /&gt;
&lt;pre class="sourcecode"&gt;Set GraphHelper = new class1&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Once you do so, you can freely use your array. &lt;br /&gt;
VB will call let and get when you try to assign a value to an array item (Let) or read an item from the array (Get). if you're unsure of how it works, just put in the Get and Let procedures a breakpoint.&lt;br /&gt;
&lt;br /&gt;
Anyway, if you write: &lt;br /&gt;
&lt;pre class="sourcecode"&gt; GraphHelper.GArray(1, 2) = "MyValue"&lt;/pre&gt;&lt;br /&gt;
VB, upon compiling, will roughly translate this to: &lt;br /&gt;
&lt;pre class="sourcecode"&gt; GraphHelper.Let_GArray(1, 2, "MyValue")&lt;/pre&gt;&lt;br /&gt;
which explains about the extra parameter in the Let property. &lt;br /&gt;
&lt;br /&gt;
Writing: &lt;br /&gt;
&lt;pre class="sourcecode"&gt; 
Dim s as string
s = GraphHelper.GArray(1, 2)&lt;/pre&gt;&lt;br /&gt;
will translate to: &lt;br /&gt;
&lt;pre class="sourcecode"&gt; s = GraphHelper.Get_GArray(1, 2)&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
I hope it's clearer. Now for a few more hints: &lt;br /&gt;
&lt;br /&gt;
- Using a standard module instead of a class module might be handier, since it means you don't have to declare and instance it (and use the "object.property" call either). Class modules are meant for classes - things you can have multiple "copies" of. You can simply cut and paste the code in your "class1" module (the same you posted here) into a standard module, and then forget about everything said above and use it like you would with any global array named GArray (well, except ReDim). &lt;br /&gt;
&lt;br /&gt;
- The array declaration you posted is fine and well, but the second dimension has no lower bound. I'd declare it as "Private GraphicArr(1 To 2, &lt;strong&gt;1 to&lt;/strong&gt; 50) As String ". More like a style thing, but are you sure that lower array bounds are the ones you expect them to be? As a rule of thumb, when in doubt, always specify. &lt;br /&gt;
&lt;br /&gt;
- Again for the array declaration: defining a lower bound of 1 for arrays is fine and well; however, it your program has a future, you'd better plan for VB.NET compatibility in advance and save pain later. In VB.NET ("VB7", although actually no VB at all), all arrays are zero-based, so it's safer to zero-base them ("Private GraphicArr(0 To 1, 0 to 49) As String "). While it's pretty painless for you to do so in VB6, it won't be as painless if you will ever need to find all the indexes in your code to decrease them by one to convert it to VB.NET. Again, it might not be your case. On a side note, I'm not sure about Option Base in VB.NET, so if you're using it, don't trust it too much.&lt;br /&gt;
&lt;br /&gt;
EDIT: infidel pointed me out a copy-and-paste error :/&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/VBasic/287230/287260/re-declaring-public-array/#287260</guid>
      <pubDate>Tue, 04 Jan 2005 02:25:30 -0700</pubDate>
      <category>Visual Basic</category>
    </item>
    <item>
      <title>Re: declaring public array</title>
      <link>http://www.programmersheaven.com/mb/VBasic/287230/287307/re-declaring-public-array/#287307</link>
      <description>: Writing: &lt;br /&gt;
: &lt;pre class="sourcecode"&gt; 
: Dim s as string
: s = GraphHelper.GArray(1, 2) = "MyValue"&lt;/pre&gt;&lt;br /&gt;
: will translate to: &lt;br /&gt;
: &lt;pre class="sourcecode"&gt; s = GraphHelper.Get_GArray(1, 2)&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Are you sure about that?  Won't s hold a boolean value?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: large;"&gt;&lt;em&gt;&lt;span style="color: Blue;"&gt;&lt;span style="color: Red;"&gt;i&lt;/span&gt;nfidel&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;pre class="sourcecode"&gt;
$ select * from users where clue &amp;gt; 0
no rows returned
&lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/VBasic/287230/287307/re-declaring-public-array/#287307</guid>
      <pubDate>Tue, 04 Jan 2005 09:01:01 -0700</pubDate>
      <category>Visual Basic</category>
    </item>
    <item>
      <title>Re: declaring public array</title>
      <link>http://www.programmersheaven.com/mb/VBasic/287230/287313/re-declaring-public-array/#287313</link>
      <description>: : Writing: &lt;br /&gt;
: : &lt;pre class="sourcecode"&gt; 
: : Dim s as string
: : s = GraphHelper.GArray(1, 2) = "MyValue"&lt;/pre&gt;&lt;br /&gt;
: : will translate to: &lt;br /&gt;
: : &lt;pre class="sourcecode"&gt; s = GraphHelper.Get_GArray(1, 2)&lt;/pre&gt;&lt;br /&gt;
: &lt;br /&gt;
: Are you sure about that?  Won't s hold a boolean value?&lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: &lt;span style="font-size: large;"&gt;&lt;em&gt;&lt;span style="color: Blue;"&gt;&lt;span style="color: Red;"&gt;i&lt;/span&gt;nfidel&lt;/span&gt;&lt;/em&gt;&lt;/span&gt;&lt;br /&gt;
: &lt;br /&gt;
: &lt;pre class="sourcecode"&gt;
: $ select * from users where clue &amp;gt; 0
: no rows returned
: &lt;/pre&gt;&lt;br /&gt;
&lt;br /&gt;
Well, yes and no. &lt;br /&gt;
It would contain a boolean value converted to a string. &lt;br /&gt;
&lt;br /&gt;
Actually, I edited the post... I made a copy-and-paste typo back there, thank you for pointing it out :/&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/VBasic/287230/287313/re-declaring-public-array/#287313</guid>
      <pubDate>Tue, 04 Jan 2005 09:33:18 -0700</pubDate>
      <category>Visual Basic</category>
    </item>
  </channel>
</rss>