|
Hi
I have a very big problem, if you know the answer please please help me.
I have a .Xls file that it has just one column data ( in the type of float). I have to read these data from Xls file and put them on an Array to use in my program, and after some working, I have to write them to an Xls file(different from the first one). It should be as a function().
I`ll really appreciate for your quick replies.
This is my email: z_eftekhari@yahoo.com
|
|
|
|
|
Em, try type some key word of your problem on google.
Possiblely you'll find your answer.
that's what i do most of the time.
|
|
|
|
|
The following VB code is FYI, you must change it to VC
////////////////////////////////////////////////////////////////
Public Function SheetToArray(strFilename As String, intSheetIndex As Integer, intRows As Integer, intColums As Integer, strArray() As String) As Boolean
'Declare objects
Dim excapp As Excel.Application
Dim excbook As Excel.Workbook
Dim excsheet As Excel.Worksheet
ReDim strArray(1 To intRows, 1 To intColums)
Dim intLoopR As Integer
Dim intLoopC As Integer
'Create objects
Set excapp = CreateObject("Excel.application")
Set excbook = excapp.Workbooks.Open(strFilename)
Set excsheet = excbook.Worksheets(intSheetIndex)
'Read the table and fill the array
For intLoopR = 1 To intRows
For intLoopC = 1 To intColums
strArray(intLoopR, intLoopC) = excsheet.Cells(intLoopR, intLoopC)
'excsheet.Range(excsheet.Cells(1, 1), excsheet.Cells(5, 5)).Select
Next intLoopC
Next intLoopR
'Close Excel
excbook.Close
excapp.Quit
'Clear the objects
Set excapp = Nothing
Set excbook = Nothing
Set excsheet = Nothing
SheetToArray = True
Exit Function
End Function
Lane
China
|
|
|
|
|
I know of two ways. The first is to use Excel's ODBC driver. The second is to use Excel Automation. In my opinion, the ODBC method would be easier for what you are doing.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
In my Vc++ dialog application , i need to launch the device manager . Is Createprocess the proper way to launch it or is there an alternative ?
Engineering is the effort !
|
|
|
|
|
you are trying to start a control panel applet i.e. a .cpl file.
I do not know (forgot) how to launch a .cpl file but you should find few expamples here or on the net on how to launch any .cpl file.
you can google it as Here[^]
-prakash
|
|
|
|
|
Why not use
rundll32.exe devmgr.dll DeviceManager_Execute
with CreateProcess() ?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
hi, all
I kinda fixed the issue but still not sure what's wrong with the previous method.
it was having access violation at this point:
void CSurchrgDlg::Exit()
{
if( !m_bCanceled )
{
.....
}
CDialog::OnCancel();
}
now I used "PostMessage( cDlg->GetSafeHwnd(), WM_QUIT, 0, 0 );" replaced the exit funtion at the end of RUN. seems to work.
OR I used PostMessage(WM_QUIT); to replace CDialog::OnCancel(); would work, too.
could someone tell me what's wrong with the calling the CDialog::OnCancel();? Thank you for your time!
-- modified at 17:59 Monday 3rd October, 2005
|
|
|
|
|
If you are multithreading you cant call thouse funtions from another thread.
I dont know if I guessed it rite.
-prakash
|
|
|
|
|
Hi for all
I would like to know what is these types of variables
HDC, HWND, HGLRC.
Thanks a lot
|
|
|
|
|
They are all handles.
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
what is the different between them?
I
|
|
|
|
|
HDC - Device handle to Device Context.
HWND - Handle to window.
HGLRC - I dont remember (need to lookup)
Basically they are all handles, i.e. The handles are just a 32bit value and nothing more then that.
It is one of the way of hinding the data that the window is using for displaying the window and the user can work on it only by passing the handle to appropriate windows function.
-prakash
|
|
|
|
|
is HGLRC an OpenGL rendering context ?
|
|
|
|
|
yes
-prakash
|
|
|
|
|
when I try to use this optimization (Visual Studio .NET 2003) I get the following compiler error:
error C2664: '_beginthread' : cannot convert parameter 1 from 'void (void *)' to 'void (__cdecl *)(void *)'
any workarround to avoid this or any other way of use threads and __fastcall optimizations. I need to kill the thread from the class where is created when this class is clossing.
regards.
|
|
|
|
|
So what does the call to _beginthread() look like?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
*** Disclaimer: i might not fully understand what you're trying to do ***
_beginthread() takes the address of a function meant to be called using the __cdecl calling convention. If you want to start a thread using _beginthread() , you will create a __cdecl function (just put __cdecl before the function name) and pass the address in. End of story.
Mostly OT, but keep in mind that it's usually a bad idea to kill threads from other threads - best off setting a flag and letting the thread process exit when it gets around to checking it.
|
|
|
|
|
what I meant by killing is:
//this is done in the OnShowWindow function because I only need the thread
// running when dialog is shown.
if(bShow)
{
m_hThread = (HANDLE)_beginthread(reader,0,this);
}
else
{
::GetExitCodeThread(m_hThread,&dwExitCode);
if (STILL_ACTIVE == dwExitCode)
{
::TerminateThread(m_hThread,dwExitCode);
::CloseHandle(m_hThread);
};
m_hThread=NULL;
};
so how should I call "reader" and how is the definition of reader to avoid
compiler error when using __fastcall convention?.
regards.
|
|
|
|
|
DaviziN wrote:
so how should I call "reader"
You do not explicitly call this function. It is the starting address for the secondary thread.
DaviziN wrote:
how is the definition of reader to avoid
compiler error when using __fastcall convention?.
The prototype for it should look like:
void __cdecl reader( void * );
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
DaviziN wrote:
what I meant by killing is:
First off, don't use TerminateThread() - it doesn't give the thread a chance to clean up after itself, and is pretty much just asking for trouble.
The simplest way to close the thread cleanly is to have a global variable somewhere, and check it from within the thread - when the variable is set, the thread knows to exit. You could also use an Event object. Either way, you can then wait for it to end safely before continuing.
|
|
|
|
|
This is not *exactly* a VC++ question, but bear with me
The following code works fine on VC6/7.1
#include <stdio.h>
void doit( const char* &g )
{
g++;
}
int main( int argc, char** argv )
{
char* s = "Hello";
printf( "%s\n", s );
doit( s );
printf( "%s\n", s );
return 0;
}
So why does GCC piss and moan about it? Is there something I'm missing? Specifically it(GCC) claims that the function call to doit() is bad because
test.cpp:13: error: invalid initialization of reference of type 'const char*&'
from expression of type 'char*'
test.cpp:5: error: in passing argument 1 of `void doit(const char*&)'
Any idea why VC7.1 doesn't flag this? I wanted the function doit() to potentially increment the pointer but NOT change it's value. So you'd see
Hello
ello
for the output of the test.
Is there a better way to accomplish this?
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
-- modified at 14:01 Monday 3rd October, 2005
|
|
|
|
|
Jim Crafton wrote:
Any idea why VC7.1 doesn't flag this? I wanted the function doit() to potentially increment the pointer but NOT change it's value. So you'd see
Hello
ello
for the output of the test.
Is there a better way to accomplish this?
Look , for example we have two functions :
void doit1( const char *g )
{
cout<<&g<<" ";
cout<<g<<" ";
cout<<*g;
cout<<endl;
g++;
}
void doit( const char *&g )
{
cout<<&g<<" ";
cout<<g<<" ";
cout<<*g;
cout<<endl;
g++;
}
int _tmain(int argc, _TCHAR* argv[])
{
char* VALUE = "Hello";
doit1(VALUE);
cout<<s<<endl;
doit(VALUE);
cout<<s<<endl;
return 0;
}
in case (A) when function doit1() is executed you pass to this function as avalue a pointer to char. So inside doit1() function, new const char* g object is created
and it is pointing to VALUE , so when you write g++ ,nothing happens with VALUE , only g is pointing to a new address , so when function ends.VALUE remains the same.
in case (B) when function doit() is executed you pass to this function a reference to pointer to char. So inside doit() no objects are cerated and you are operating straight with the address of VALUE , so when you write g++ , VALUE -s address changes and therefore when function ends "ello" is printed.
clear??
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
-- modified at 15:19 Monday 3rd October, 2005
|
|
|
|
|
Thanks!
That's what I thought was going on. So why does GCC flag it (in your example, function B) as an error? That's what is really bugging me. It seems to me that this is perfectly acceptable and correct C++.
¡El diablo está en mis pantalones! ¡Mire, mire!
Real Mentats use only 100% pure, unfooled around with Sapho Juice(tm)!
SELECT * FROM User WHERE Clue > 0
0 rows returned
Save an Orange - Use the VCF!
|
|
|
|
|
Jim Crafton wrote:
So why does GCC flag it (in your example, function B) as an error?
no idea
Jim Crafton wrote:
It seems to me that this is perfectly acceptable and correct C++.
to me too
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|