Re: Variable for a Variable



Hello Frank.

I certainly can see the advantage to your suggestion. The reason I
originally went the other way (wrong way - duh beginner here) is that each
tool had has completely different elements that describe them.

For example:

The Trendline tool requires:

Cordinates x1, x2, y1, y2.
Record Number (to ID price bar)
Time Frame (Daily, Weekly or Monthly)
Visible (for delete purposes)
Color
....


Then say the FibLines tool requires:

Record Number A (for starting price bar - x axis coordinates)
PriceA (for starting price bar high/low price - y axis coordinates)

Record Number B (for ending price bar)
Price B

Time Frame (D,W,M)
Visible
Color
Type (Retracement/Expansion/Alt-Expansion)


Can you see what I mean? Each tool has their own UNIQUE requirements to
locate, identify, create, etc.

Now I could create a TOOL_STRUC that simply contained every possible tool
variable I'll need. But would that be a better way to go than rather having
these unique STRUCS due to the tools being so diverse?

Yes, they do all have some items in common.

Color
Visible
Time Frame

What do you think?

THANKS A BUNCH. :-)



"Frank Adam" <fajp@xxxxxxxxxxxxxxxxxxxx> wrote in message
news:nm63m15h58f3mktl7vetlp8bf3dvuh56pk@xxxxxxxxxx
> On Thu, 27 Oct 2005 20:48:15 -0500, "ProfitMaxTrading.com"
> <nospam@xxxxxxxxxx> wrote:
>
>>And therefore be able to do this:
>>
>> sArrayName = ToolName(Tool_ID)
>> sArrayName(iElements).Visible = False
>>
>>??
>>
>>Is this possible? Or is the language limited in this respect?
>>
> If i understand what you mean, you are going about this the wrong way.
> Code speaks volumes, so..
>
> use constants for the IDs
>
> private const T_SAW = 0
> private const T_DRILL = 1
> etc..
>
> Private Type TOOLS_T
> tID as long
> visible as boolean
> tNames() as string
> End type
>
> dim tools(30) as TOOLS_T
>
> ' Us this function to add each tool.
> 'remember the ID corresponds to the index of the tools in this sample.
> ' So tools(0) = Saw, tools(1) = drill
> 'If later it has to become dynamic, so you can add tools, that's no
> ' big problem, it would just need a bit of rewrite on the dims and a
> ' simple lookup function added.
> Private Sub AddTool(s as string, id as long)
> dim i as long 'index into tName array
> with tools(id)
> on error resume next
> i = ubound(.tNames)
> if err.number = 0 then 'it's been dimmed once
> i = i + 1 'so add one.
> end if
> on error goto 0
> redim preserve .tNames(i)
> .tNames(i) = s
> end with
> end sub
>
> Sub SelectTool(id as long)
> tools(id).visible = true
> end sub
>
> Private sub Form_Load()
> call AddTool("Bosch",T_DRILL)
> call Addtool("Makita",T_DRILL)
> call AddTool("Stanley",T_SAW)
> call SelectTool(T_DRILL)
> debug.print tools(T_DRILL).tNames(0), tools(T_DRILL).visible
> debug.print tools(T_DRILL).tNames(1), tools(T_DRILL).visible
> debug.print tools(T_SAW).tNames(0), tools(T_SAW).visible
> End sub
>
> See if you can build around that idea better ?
>
> --
>
> Regards, Frank


.



Relevant Pages

  • Re: Is there a way to prevent a RichTextBox from scrolling?
    ... Private _isRegex As Boolean ... Public Sub New(ByVal thispattern As String, ... Dim entry As tDict ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Project Error
    ... Private Declare Sub Sleep Lib "Kernel32" ... Dim strDataSrc As String ...
    (microsoft.public.vb.bugs)
  • MAPI Emails from Access
    ... I realize this code is quite long, but could someone take a look at the sub ... Private Const mcERR_DOH = vbObjectError + 10000 ... Private mstStatus As String ... Dim db As Database, rs As Recordset ...
    (microsoft.public.access.formscoding)
  • Re: Sorting a System.Collections.ObjectModel.Collection
    ... Public Sub Dispose() Implements System.IDisposable.Dispose ... Private m_SupportsSorting As Boolean = True ... Protected Overrides ReadOnly Property SupportsSortingCoreAs Boolean ... Dim m_SortList As New ArrayList ...
    (microsoft.public.dotnet.languages.vb)
  • Re: "Subclassing" a property let
    ... Private Sub Form_Initialize ... Dim m_ForceShowInTaskbar As Boolean ... ByVal lParam As Long) As Long ...
    (microsoft.public.vb.com)