Hi,

Is there a faster means by which I can get data from an edit box and assign them to an array.

lets say I got this intergers m_1....m_100, and I want to put the values to an int val[10][10] whaat I did was to hard code each interger to each array elements. something like this...

UpdateData(TRUE); // pass the values of the edit boxes

val[0][0] = m_1;
val[0][1] = m_2;
.
.
.
val[0][9]=m_10;
.
.
.
and so on..


this is too tedious, can someone help me with this one. I know I'm missing some tips , a trick or two. Pls help.Thanks. :confused:

Recommended Answers

All 3 Replies

Yes. After using ClassWizard to generate all the variable names, such as m_m1 through m_m10, then create your own int array and replace all those variables with your array You will need to delete (or comment out) the m_m1 ... varaibel in the .h file and in the .cpp file. Then make the change below in the DoDataExchange() method.

void CMyDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTest2Dlg)
	DDX_Text(pDX, IDC_EDIT1, m_array[0]);
	DDX_Text(pDX, IDC_EDIT2, m_array[1]);
	DDX_Text(pDX, IDC_EDIT3, m_array[2]);
	DDX_Text(pDX, IDC_EDIT4, m_array[3]);
	DDX_Text(pDX, IDC_EDIT5, m_array[4]);
	DDX_Text(pDX, IDC_EDIT6, m_array[5]);
	DDX_Text(pDX, IDC_EDIT7, m_array[6]);
	DDX_Text(pDX, IDC_EDIT8, m_array[7]);
	DDX_Text(pDX, IDC_EDIT9, m_array[8]);
	DDX_Text(pDX, IDC_EDIT10, m_array[9]);
	//}}AFX_DATA_MAP
}

hi,

whew,that was fast.. lotsa thanks man.

Yes. After using ClassWizard to generate all the variable names, such as m_m1 through m_m10, then create your own int array and replace all those variables with your array You will need to delete (or comment out) the m_m1 ... varaibel in the .h file and in the .cpp file. Then make the change below in the DoDataExchange() method.

void CMyDlg::DoDataExchange(CDataExchange* pDX)
{
	CDialog::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CTest2Dlg)
	DDX_Text(pDX, IDC_EDIT1, m_array[0]);
	DDX_Text(pDX, IDC_EDIT2, m_array[1]);
	DDX_Text(pDX, IDC_EDIT3, m_array[2]);
	DDX_Text(pDX, IDC_EDIT4, m_array[3]);
	DDX_Text(pDX, IDC_EDIT5, m_array[4]);
	DDX_Text(pDX, IDC_EDIT6, m_array[5]);
	DDX_Text(pDX, IDC_EDIT7, m_array[6]);
	DDX_Text(pDX, IDC_EDIT8, m_array[7]);
	DDX_Text(pDX, IDC_EDIT9, m_array[8]);
	DDX_Text(pDX, IDC_EDIT10, m_array[9]);
	//}}AFX_DATA_MAP
}

lotsa thanks man for the fast reply.you are so right.

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.