what am i doing wrong here?
Author Message
what am i doing wrong here?

---------------    WORK -----------------
Dim Mech1, Mech2, Mech3, Mech4, Mech5, Mech6, Mech7, Mech8, Mech9, Mech10,
Mech11, Mech12, Mech13, Mech14, Mech15, Mech16, Mech17, Mech18, Mech19,
Mech20, Mech21, Mech22, Mech23, Mech24 As String

'Dim MechPart1, MechPart2, MechPart3, MechPart4, MechPart5, MechPart6,
MechPart7, MechPart8, MechPart9, MechPart10, MechPart11, MechPart12,
MechPart13, MechPart14, MechPart15, MechPart16, MechPart17, MechPart18,
MechPart19, MechPart20, MechPart21, MechPart22, MechPart23, MechPart24,
MechPart25, MechPart26, MechPart27, MechPart28, MechPart29, MechPart30,
MechPart31, MechPart32, MechPart33, MechPart34, MechPart35, MechPart36,
MechPart37, MechPart38 As String

If Left\$(data2, 6) = "Part1:" Then Mech1 = data2
If Left\$(data2, 6) = "Part2:" Then Mech2 = data2
If Left\$(data2, 5) = "Part3" Then Mech3 = data2
If Left\$(data2, 5) = "Part4" Then Mech4 = data2
If Left\$(data2, 5) = "Part5" Then Mech5 = data2
If Left\$(data2, 5) = "Part6" Then Mech6 = data2
If Left\$(data2, 5) = "Part7" Then Mech7 = data2
If Left\$(data2, 5) = "Part8" Then Mech8 = data2
If Left\$(data2, 5) = "Part9" Then Mech9 = data2
If Left\$(data2, 6) = "Part10" Then Mech10 = data2
If Left\$(data2, 6) = "Part11" Then Mech11 = data2
If Left\$(data2, 6) = "Part12" Then Mech12 = data2
If Left\$(data2, 6) = "Part13" Then Mech13 = data2
If Left\$(data2, 6) = "Part14" Then Mech14 = data2
If Left\$(data2, 6) = "Part15" Then Mech15 = data2
If Left\$(data2, 6) = "Part16" Then Mech16 = data2
If Left\$(data2, 6) = "Part17" Then Mech17 = data2
If Left\$(data2, 6) = "Part18" Then Mech18 = data2
If Left\$(data2, 6) = "Part19" Then Mech19 = data2
If Left\$(data2, 6) = "Part20" Then Mech20 = data2
If Left\$(data2, 6) = "Part21" Then Mech21 = data2
If Left\$(data2, 6) = "Part22" Then Mech22 = data2
If Left\$(data2, 6) = "Part23" Then Mech23 = data2
If Left\$(data2, 6) = "Part24" Then Mech24 = data2

MechPart1 = Split(Mech1, Chr\$(58))
MechPart2 = Split(Mech2, Chr\$(58))
MechPart3 = Split(Mech3, Chr\$(58))
MechPart4 = Split(Mech4, Chr\$(58))
MechPart5 = Split(Mech5, Chr\$(58))
MechPart6 = Split(Mech6, Chr\$(58))
MechPart7 = Split(Mech7, Chr\$(58))
MechPart8 = Split(Mech8, Chr\$(58))
MechPart9 = Split(Mech9, Chr\$(58))
MechPart10 = Split(Mech10, Chr\$(58))
MechPart11 = Split(Mech11, Chr\$(58))
MechPart12 = Split(Mech12, Chr\$(58))
MechPart13 = Split(Mech13, Chr\$(58))
MechPart14 = Split(Mech14, Chr\$(58))
MechPart15 = Split(Mech15, Chr\$(58))
MechPart16 = Split(Mech16, Chr\$(58))
MechPart17 = Split(Mech17, Chr\$(58))
MechPart18 = Split(Mech18, Chr\$(58))
MechPart19 = Split(Mech19, Chr\$(58))
MechPart20 = Split(Mech20, Chr\$(58))
MechPart21 = Split(Mech21, Chr\$(58))
MechPart22 = Split(Mech22, Chr\$(58))
MechPart23 = Split(Mech23, Chr\$(58))
MechPart24 = Split(Mech24, Chr\$(58))

'Form4.RichTextBox1.Text = mechPart1 '[type mismatch?] or [ bad subscript
error 9]

Form4.RichTextBox1.Text = Mech1 [prints the entire lie of data2 un split]
-------------
I need to have  form4Richtextbox.text = mechpart1(0) & mechpart1(1) and so
on [ then i can access the array indexd data]
the textbox is just a debug controll at this point.
--------------
I belive it is in the way I am dim the split array  ?
do i need to dim the split array variable at all ?
or do i need to redim it  with index size?
I ve tried several methods and none seem to work I get one of the 2 errors
above.
-----------
* Mark

'---------------  END  WORK -----------------

Fri, 15 Oct 2004 02:34:18 GMT
what am i doing wrong here?
sometimes we miss the simple things....
Dim Mech1, Mech2,  _ 'Blah,blah
As String() '!!!! Not as string

Quote:
> ---------------    WORK -----------------
> Dim Mech1, Mech2, Mech3, Mech4, Mech5, Mech6, Mech7, Mech8, Mech9, Mech10,
> Mech11, Mech12, Mech13, Mech14, Mech15, Mech16, Mech17, Mech18, Mech19,
> Mech20, Mech21, Mech22, Mech23, Mech24 As String

> 'Dim MechPart1, MechPart2, MechPart3, MechPart4, MechPart5, MechPart6,
> MechPart7, MechPart8, MechPart9, MechPart10, MechPart11, MechPart12,
> MechPart13, MechPart14, MechPart15, MechPart16, MechPart17, MechPart18,
> MechPart19, MechPart20, MechPart21, MechPart22, MechPart23, MechPart24,
> MechPart25, MechPart26, MechPart27, MechPart28, MechPart29, MechPart30,
> MechPart31, MechPart32, MechPart33, MechPart34, MechPart35, MechPart36,
> MechPart37, MechPart38 As String

> If Left\$(data2, 6) = "Part1:" Then Mech1 = data2
> If Left\$(data2, 6) = "Part2:" Then Mech2 = data2
> If Left\$(data2, 5) = "Part3" Then Mech3 = data2
> If Left\$(data2, 5) = "Part4" Then Mech4 = data2
> If Left\$(data2, 5) = "Part5" Then Mech5 = data2
> If Left\$(data2, 5) = "Part6" Then Mech6 = data2
> If Left\$(data2, 5) = "Part7" Then Mech7 = data2
> If Left\$(data2, 5) = "Part8" Then Mech8 = data2
> If Left\$(data2, 5) = "Part9" Then Mech9 = data2
> If Left\$(data2, 6) = "Part10" Then Mech10 = data2
> If Left\$(data2, 6) = "Part11" Then Mech11 = data2
> If Left\$(data2, 6) = "Part12" Then Mech12 = data2
> If Left\$(data2, 6) = "Part13" Then Mech13 = data2
> If Left\$(data2, 6) = "Part14" Then Mech14 = data2
> If Left\$(data2, 6) = "Part15" Then Mech15 = data2
> If Left\$(data2, 6) = "Part16" Then Mech16 = data2
> If Left\$(data2, 6) = "Part17" Then Mech17 = data2
> If Left\$(data2, 6) = "Part18" Then Mech18 = data2
> If Left\$(data2, 6) = "Part19" Then Mech19 = data2
> If Left\$(data2, 6) = "Part20" Then Mech20 = data2
> If Left\$(data2, 6) = "Part21" Then Mech21 = data2
> If Left\$(data2, 6) = "Part22" Then Mech22 = data2
> If Left\$(data2, 6) = "Part23" Then Mech23 = data2
> If Left\$(data2, 6) = "Part24" Then Mech24 = data2

> MechPart1 = Split(Mech1, Chr\$(58))
> MechPart2 = Split(Mech2, Chr\$(58))
> MechPart3 = Split(Mech3, Chr\$(58))
> MechPart4 = Split(Mech4, Chr\$(58))
> MechPart5 = Split(Mech5, Chr\$(58))
> MechPart6 = Split(Mech6, Chr\$(58))
> MechPart7 = Split(Mech7, Chr\$(58))
> MechPart8 = Split(Mech8, Chr\$(58))
> MechPart9 = Split(Mech9, Chr\$(58))
> MechPart10 = Split(Mech10, Chr\$(58))
> MechPart11 = Split(Mech11, Chr\$(58))
> MechPart12 = Split(Mech12, Chr\$(58))
> MechPart13 = Split(Mech13, Chr\$(58))
> MechPart14 = Split(Mech14, Chr\$(58))
> MechPart15 = Split(Mech15, Chr\$(58))
> MechPart16 = Split(Mech16, Chr\$(58))
> MechPart17 = Split(Mech17, Chr\$(58))
> MechPart18 = Split(Mech18, Chr\$(58))
> MechPart19 = Split(Mech19, Chr\$(58))
> MechPart20 = Split(Mech20, Chr\$(58))
> MechPart21 = Split(Mech21, Chr\$(58))
> MechPart22 = Split(Mech22, Chr\$(58))
> MechPart23 = Split(Mech23, Chr\$(58))
> MechPart24 = Split(Mech24, Chr\$(58))

> 'Form4.RichTextBox1.Text = mechPart1 '[type mismatch?] or [ bad subscript
> error 9]

> Form4.RichTextBox1.Text = Mech1 [prints the entire lie of data2 un split]
> -------------
> I need to have  form4Richtextbox.text = mechpart1(0) & mechpart1(1) and so
> on [ then i can access the array indexd data]
> the textbox is just a debug controll at this point.
> --------------
> I belive it is in the way I am dim the split array  ?
> do i need to dim the split array variable at all ?
> or do i need to redim it  with index size?
> I ve tried several methods and none seem to work I get one of the 2 errors
> above.
> -----------
> * Mark

> '---------------  END  WORK -----------------

Fri, 15 Oct 2004 02:54:53 GMT
what am i doing wrong here?

Quote:

> Dim Mech1, Mech2, Mech3, Mech4, Mech5, Mech6, Mech7, Mech8, Mech9, Mech10,
> Mech11, Mech12, Mech13, Mech14, Mech15, Mech16, Mech17, Mech18, Mech19,
> Mech20, Mech21, Mech22, Mech23, Mech24 As String

Dim Mech(1 To 24) As String

Refer to elements using Mech(1), Mech(2), etc.

Quote:
> If Left\$(data2, 6) = "Part1:" Then Mech1 = data2
> If Left\$(data2, 6) = "Part2:" Then Mech2 = data2
> If Left\$(data2, 5) = "Part3" Then Mech3 = data2
> [...]

Use the string-handling commands (Mid\$ and Right\$ would probably be useful
here) to isolate the part of the string containing the digits, and then Val
to extract those digits from the string. Then you have an numerical index
you can use in the form Mech(Index).

Declaring each element as a separate variable (Mech1, Mech2, ...) is
inflexible and tedious, and it will certainly make your code a lot longer
than it needs to be.

Eq.

--

Equinox Tetrachloride
www.cl4.org - www.insecurities.org

Fri, 15 Oct 2004 02:59:58 GMT
what am i doing wrong here?

You have a bunch of variants there with a solo String declared on the
ends.
Mech1 - Mech23 are variants. So are MechPart1 - Mechpart37.
So when you split into them, if there is two sides to the split
(presumably so) then you can no longer assign the variant to the .Text
of the RT, since it is now an array of strings.
Similarly, you will error out when trying to split into the the
solitary string Mechpart38.
My advice is to change the As String into an As Variant for the
MechParts. the other one doesn;t matter, apart from being wasteful.
Then assign MechPart1(0), MechPart2(0) etc.. to the text.

Hope this helps. :-)

Quote:
>---------------    WORK -----------------
>Dim Mech1, Mech2, Mech3, Mech4, Mech5, Mech6, Mech7, Mech8, Mech9, Mech10,
>Mech11, Mech12, Mech13, Mech14, Mech15, Mech16, Mech17, Mech18, Mech19,
>Mech20, Mech21, Mech22, Mech23, Mech24 As String

>'Dim MechPart1, MechPart2, MechPart3, MechPart4, MechPart5, MechPart6,
>MechPart7, MechPart8, MechPart9, MechPart10, MechPart11, MechPart12,
>MechPart13, MechPart14, MechPart15, MechPart16, MechPart17, MechPart18,
>MechPart19, MechPart20, MechPart21, MechPart22, MechPart23, MechPart24,
>MechPart25, MechPart26, MechPart27, MechPart28, MechPart29, MechPart30,
>MechPart31, MechPart32, MechPart33, MechPart34, MechPart35, MechPart36,
>MechPart37, MechPart38 As String

<snip>

Regards, Frank

Fri, 15 Oct 2004 03:40:59 GMT
what am i doing wrong here?
Thanks for your help I have it working now
this is what i have wound up with
I did change the delimiter to a "/" but that wasn't the problem just made it
easer to see the delimiter.
origionaly I was trying to split the variable I assigned the data to
by changing to spliting the data and following through on the IF then branch
it works.

Dim Mech1, Mech2, Mech3, Mech4, Mech5, Mech6, Mech7, Mech8, Mech9, Mech10,
Mech11, Mech12, Mech13, Mech14, Mech15, Mech16, Mech17, Mech18, Mech19,
Mech20, Mech21, Mech22, Mech23, Mech24 As String

[ could do 1 or two for next loops here for this check] then gosub
Mechweaponsid:

If Left\$(data2, 6) = "Part1/" Then GoSub Mechweaponsid:
If Left\$(data2, 6) = "Part2/" Then GoSub Mechweaponsid:
If Left\$(data2, 6) = "Part3/" Then GoSub Mechweaponsid:
If Left\$(data2, 6) = "Part4/" Then GoSub Mechweaponsid:
If Left\$(data2, 6) = "Part5/" Then GoSub Mechweaponsid:
If Left\$(data2, 6) = "Part6/" Then GoSub Mechweaponsid:
If Left\$(data2, 6) = "Part7/" Then GoSub Mechweaponsid:
If Left\$(data2, 6) = "Part8/" Then GoSub Mechweaponsid:
If Left\$(data2, 6) = "Part9/" Then GoSub Mechweaponsid:
If Left\$(data2, 6) = "Part10" Then GoSub Mechweaponsid:
If Left\$(data2, 6) = "Part11" Then GoSub Mechweaponsid:
If Left\$(data2, 6) = "Part12" Then GoSub Mechweaponsid:
If Left\$(data2, 6) = "Part13" Then GoSub Mechweaponsid:

GoTo continue:

Mechweaponsid:

NL = Chr\$(10)
Mech1 = Split(data2, "/")
For no = 0 To UBound(Mech1)
If Mech1(no) = "Part1" Then Form4.Label4.Caption = "Part1"
If Mech1(no) = "uc MasterID=154" Then weapon1 = weapon1 & "Clan - ER PPC" &
NL

Form4.RichTextBox1.Text = weapon1
Next
Return
continue:

One more question [ to save some coding ]  can I use a multidimentional
array here?
such as Mech(x) = Split(data2, "/")
If mech(1)(no) = "Part1" then x = y
basicly can I build a 0 based array off an array(index) ?
if not ill have to code each mech1 to mech 24 seperetly about 40 lines of
code for each of 24 mechs

Fri, 15 Oct 2004 11:44:16 GMT

 Page 1 of 1 [ 5 post ]

Relevant Pages