Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How can I feed data in an array between forms?

Posted on 2001-06-16
5
Medium Priority
?
150 Views
Last Modified: 2010-05-02
Hi,

I'm having trouble feeding the results of a calculation from one form, into another form, where the data will be plotted in a graph.  At the moment, the user must save the data in a data file, then load it again into the graph-plotting programme.  This event is very slow.  The user is required to specify the number of columns of data in the file - but the number of columns is not fixed and changes frequently.  I would like to offer the user a menu-option to "Plot graph", whereupon the calculated data in columns will be fed directly into the the graph plotting programme.  I've found this to be a challenge!  

Can anyone help me to do this?

Also, how does one define the "Select All" command in the Edit menu?

Many thanks,

Andrew
0
Comment
Question by:alouka
[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
5 Comments
 
LVL 2

Accepted Solution

by:
PeteD earned 300 total points
ID: 6197994
Whatever the format of your data, devlare the variable as public in a module,

e.g.

Public Mydata(1 to 10) as Long

then you can access the data from any form in the same project.

Also to select all try:

Private Sub mnuSelectAll_Click()
    If TypeOf Me.ActiveControl Is TextBox Then
        Me.ActiveControl.SelStart = 0
        Me.ActiveControl.SelLength = Len(Me.ActiveControl)
    End If
End Sub
0
 
LVL 3

Expert Comment

by:RodStephens
ID: 6198068
It sounds like the data plotting program is one you didn't write. True?

If so, transferring the data may be hard. You can find the other application and use SendKeys to send it data, though it's non-trivial. How hard it is depends on the other application. Look into OLE in case the application has an OLE interface. If you are writing it, you can use OLE, too.

A Select All command depends on how you define your application and its data. When the user selects a Copy command, you need to put the data on the clipboard in a format that some other application might understand. For example, you might try separating the items with commas and the rows with semi-colons. Or tabs between items and vbCrLf between rows. There's no guarantee another application will know how to paste the data, though.
0
 

Author Comment

by:alouka
ID: 6200206
I wrote all the programs myself but unfortunately I am not familiar with the OLE interface.  I started learning Visual Basic about 4 months ago.  My programs are intended for electrical and control engineers. I can plot linear and log./linear graphs with or without a full grid.  The calculated results using equations for example are stored in an array and then saved in a data file. This process is fairly fast. When opening the file however, the process is very slow so I am hoping that there is a way of transferring the data stored in an array when using one form to an array in the graph plotting program which is part of the same project.
Thank you very much RodStephens and PeterG for your replies. The Select All Sub from PeterG works fine-thank you. The declaration Public A(1001,10) As Single was rejected by the program.

Thanks again.
0
 

Author Comment

by:alouka
ID: 6200376
Please see my comment posted earlier!
0
 
LVL 1

Expert Comment

by:NickLo
ID: 6221571
The following method of transferring numeric data stored in an array from one Form to another Form actually works but it is not a direct method. Perhaps someone else knows a more direct method.

Add a TextBox on Form1(Form), name it say txtRxd, and set its properties Multiline to False and Visible to False.  Add also a command button or a menu option for listing the numeric values in the Main TextBox - Say Name: cmdList and Caption &List.
Declare the variables
eg Dim I1, Rows, Column As Integer
   Dim A(501,12) As Single ' Dimention according to the requirement.

On Form1(Code) enter the following:-

Private Sub Form_Load()
I1 = 0: Rows = 0
End Sub

Sub MatValues()
A(Row, I1) = txtRxd.Text
txtRxd.Text = ""
I1 = I1 + 1
If I1 > Column -1 Then
I1 = 0
Row = Row + 1
End If
End Sub

Sub MatValues1()
Column = CInt(txtRxd.Text)
txtRxd.Text = ""
End Sub
Public Sub cmdList_Click()
txtMain.Text = ""
For J1 = 0 To Row - 1
For I1 = 0 To Column -1
txtMain.Text = txtMain.Text & "        " & Format(A(J1, I1), "###0.0000")
Next I1
txtMain.Text = txtMain.Text & vbCrLf
Next J1
End Sub

On the second Form2(Form), add a command button and name it cmdTxd. On the Form2(Code) from which the numeric data is to be transferred, Declare the variables I1,J1,Row,Column As Integer and the array A(501,12) As Single or what ever other array used.

Private Sub cmdTxd_Click()
Form1.txtRxd.Text = Columns
Form1.MatValues1
For J1 = 0 To Row - 1
For I1 = 0 To Column - 1
Form1.txtRxd.Text = Format(A(J1, I1), "#0.0###")
Form1.MatValues
Next I1
Next J1
Form1.cmdList_Click
Form2.Hide
End Sub
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

688 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