?
Solved

Visual Representation of Data with MSChart

Posted on 2003-03-11
14
Medium Priority
?
683 Views
Last Modified: 2007-11-27
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
Comment
Question by:ex279
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
14 Comments
 
LVL 9

Expert Comment

by:GivenRandy
ID: 8111540
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
 

Author Comment

by:ex279
ID: 8111573
When I do that, I get a "Compile Error: Expected Array"
0
 
LVL 9

Expert Comment

by:GivenRandy
ID: 8111669
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:ex279
ID: 8111776
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
 
LVL 9

Expert Comment

by:GivenRandy
ID: 8111863
Make sure there are parenthesis after "dim arrRTT":

Dim arrRTT()
0
 

Author Comment

by:ex279
ID: 8111885
I still get the same error "Run-time error '1101': Bad Function argument".
0
 
LVL 9

Expert Comment

by:GivenRandy
ID: 8113050
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
 

Author Comment

by:ex279
ID: 8113624
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
 

Author Comment

by:ex279
ID: 8113629
Is there another way to get data into a line graph (not using MSCHART)?
0
 
LVL 9

Accepted Solution

by:
GivenRandy earned 75 total points
ID: 8115955
Is this VB6 or VB.NET?
0
 

Author Comment

by:ex279
ID: 8116188
This is VB6
0
 

Author Comment

by:ex279
ID: 8116195
I'm trying the picture box now.  So far it looks like it's working.

picture1.line (x1,y1)-(x2,y2)
0
 

Expert Comment

by:CleanupPing
ID: 9056440
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
 
LVL 9

Expert Comment

by:GivenRandy
ID: 9063284
>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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month10 days, 7 hours left to enroll

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question