I was wondering what i would have to do if i wanted to Write a program in Visual Basic but wanted to do some calculation(as to make it quicker) in C?

Like say i wanted to fine the average of.. bah a few hundered thousand numbers in an array. So i'd imagine that might take a little while in Visual Basic(maybe not haven't tried) How would i go about recieving a value from a value from C++?

Don't really need to know, i've just been wondering lately about crossing over languages.

I've made C++ console programs and VB apps work with values together before, but not directly. I used to make either program to save the numbers, and the other to load.
example # of numbers: 32000
(I just created this code out of concept and some logic. Not sure if it would check out with the compiler.)

'VB

Dim dblArray(0 to 31999) as Double
Dim intArrayNum as Integer
Dim CurrentSum as Double
Dim dblAvg as Double

'Saving Data
Open filename For Output As 1
For dblArrayNum=0 to 31999
Write #1, intArrayNum,dblArray(intArrayNum)
Next intArrayNum
Close

'receiving and calculating part for VB(if you are 'going C++ to VB)
Open filename For Input As 1
While EOF(1)<>True
Input #1, intArrayNum,dblArray(intArrayNum)
Wend
Close

For intArrayNum=0 to 31999
CurrentSum=CurrentSum+dblArray(intArrayNum)
Next intArrayNum
dblAvg=CurrentSum/32000
/*C++. I'm learning more C++, but sloow progress. At least I can make programs crunch numbers. 
heh.*/

#include<iostream>
#include<cstdlib>
#include<fstream>
using namespace std;
ofstream read;  // global var
ifstream write;  // correct direction of input?
int main()
{
  int arrayelement; double sum; double avg;
  double array[32000]; //forgot what's the max
 //number of elements in a C++ array. let's say
// it can hold that much
read.open(filename);
for(arrayelement=0; arrayelement=32000; arrayelement++)
{ read >> array[arrayelement]; }
read.close();
for(arrayelement=0; arrayelement=32000; arrayelement++)
{sum=sum+array[arrayelement];}
solve:
avg=sum/32000;

return 0;
}

I'm so dizzy and I confused myslef after writing this code.... XD

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.