Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 691
  • Last Modified:

Visual Representation of Data with MSChart

I'm having trouble representing my data with a line graph.  Eventually I would like to export my data and graph into an HTML format, but I'm not there, yet!  I'm using the MSChart to represent the data.  I need to redim my array because the datafile size will vary.  It could have 2 or 3 results, 500, or higher in the data file.  If I do not redim my array (and statically assign it), it works, but since I need to redim the array, it doesn't and I get the following error: "Run-time error '1101': Bad Function argument".  Is there a way around this or do I need to use something else or try another method?


Private Sub RunStats()

   Dim i As Integer
   Dim NextRecord As Integer
   Dim HostAddress As String
   
   FileNo = FreeFile
   RecLength = Len(MyData(1))
   FileName = App.Path & "\data.dat"
           
   Open FileName For Random As FileNo Len = RecLength
      NextRecord = (LOF(FileNo) / Len(MyData(1)))
      Dim arrRTT
      ReDim arrRTT(1 To NextRecord)
     
      For i = 1 To NextRecord
         Get FileNo, i, MyData(1)
         arrRTT(i) = LTrim(MyData(1).RTT)
         List1.AddItem (arrRTT(i)) 'DATA CHEcK ONLY
      Next i
   Close FileNo

   MSChart1.ChartData = arrRTT

End Sub
0
ex279
Asked:
ex279
  • 7
  • 6
1 Solution
 
GivenRandyCommented:
Make sure you Dim as an array (and it is a good idea to specify the type, string in this case):

Dim arrRTT() As String
0
 
ex279Author Commented:
When I do that, I get a "Compile Error: Expected Array"
0
 
GivenRandyCommented:
The shell code worked in my example. Perhaps it is your parenthesis after AddItem? Try this:

List1.AddItem arrRTT(i) ' DATA CHEcK ONLY

Which line is causing the error?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
ex279Author Commented:
The line that is giving me the error is the "MSChart1.ChartData = arrRTT"

As for the array error, it is the "ReDim arrRTT(1 To NextRecord)".  But that is only if I "dim arrRTT as string".  If I just "dim arrRTT", it works fine.
0
 
GivenRandyCommented:
Make sure there are parenthesis after "dim arrRTT":

Dim arrRTT()
0
 
ex279Author Commented:
I still get the same error "Run-time error '1101': Bad Function argument".
0
 
GivenRandyCommented:
Is the data coming in a string of numbers (e.g., "123") or is it binary data? I see that it is getting stuffed into RTT ("arrRTT(i) = LTrim(MyData(1).RTT)"), but it needs to be the right type as well. The chart can convert string data to the numeric equivalent, but not if it is binary. This is another reason to have a type for the array (either string or long or single, whatever is appropriate).

What is the value of NextRecord? You mention that it varies (2, 3, 500, etc.), but did you debug it in this case?
0
 
ex279Author Commented:
NextRecord is actually the total number of records in the file.  NextRecord is a numeric value.  Data is being written into the array.  To test, I can loop a msgbox to echo the contents of the array and it displays it correctly.  If I don't redim the array and initally "dim arrRTT(1 to 10000)", it works, but I don't want to use the memory if I don't need it.  Also, it could go higher than 10000.
0
 
ex279Author Commented:
Is there another way to get data into a line graph (not using MSCHART)?
0
 
GivenRandyCommented:
Is this VB6 or VB.NET?
0
 
ex279Author Commented:
This is VB6
0
 
ex279Author Commented:
I'm trying the picture box now.  So far it looks like it's working.

picture1.line (x1,y1)-(x2,y2)
0
 
CleanupPingCommented:
ex279:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
GivenRandyCommented:
>Post your closing recommendations!  No comment means you don't care.

What about those of us on vacation who just got back?
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 7
  • 6
Tackle projects and never again get stuck behind a technical roadblock.
Join Now