illegal use of this type as an expression
各位好,最近学习VC++6.0,遇到两个问题不知如何解决,请高手们帮忙。
问题一: 代码如下
void CZKAMotionControlDlg::OnButtonCycle()
{
DWORD dwStart, dwEnd;
float time;
for(int i=0; i<10; i++){
dwStart = GetTickCount();
move(m_move_distance);
dwEnd = GetTickCount();
time = (dwEnd-dwStart)*1.0/1000.0; //ms
cout<<"move to start position, use time : "<<time<<endl;
string.Format("Cur. Position : %d", current_position );
GetDlgItem( IDC_STATIC_POSITION_X )->SetWindowText( string );
}
}
编译时出现错误:
error C2143: syntax error : missing ';' before '.'
error C2143: syntax error : missing ';' before '.'
error C2275: 'string' : illegal use of this type as an expression
c:\program files\microsoft visual studio\vc98\include\xstring(612) : see declaration of 'string'
问题二: 代码如下
CZKAMotionControlDlg::CZKAMotionControlDlg(CWnd* pParent /*=NULL*/)
: CDialog(CZKAMotionControlDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CZKAMotionControlDlg)
m_bX = FALSE;
m_bY = FALSE;
m_bU = FALSE;
m_bZ = FALSE;
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
CString string;
zka_get_program_version(i_board_id, version1, version2, version3);
char s[4] = {version1, version2, version3, 0};
string.Format("Program Version : %s", s);
GetDlgItem( IDC_STATIC_PROGRAM_VERSION )->SetWindowText( string ); // **********************
}
运行时出现这个对话框
Debug Assertion Failed!
Program: ...6.0\..\..\ZKAMotionControl.exe
File: winocc.cpp
Line: 76
For information on how your program can cause an assertion failure, see the Visual C++ documentation on asserts.
(Press Retry to debug the application)
程序运行终止。
问题较急,在线等待,不甚感激!