Can i know what's wrong with the below source code? can i put the variable x, y like this? How it can't work?

#include <Windows.h>
#include <mmsystem.h>
#pragma comment (lib,"winmm.lib")

int ,x,y;
void CTestingDlg::OnPlay() 
{
	// TODO: Add your control notification handler code here
			
                UpdateData(TRUE);

	CString strFreq;
	CString strHL;

	strFreq = m_strFreq;
	strHL = m_strHL;
	
	strFreq.MakeUpper();
	strHL.MakeUpper();

	if(strFreq=="x" && strHL=="y")
		   PlaySound("x_y_2.wav",NULL,SND_FILENAME);

}

what makes you think you can compare integers and strings ? Ain't going to work. If the strings contain numeric digits then convert them to integers before doing the comparison.

if it is necessary to used the variable, how should i write?

Are you new to c and c++ languages? You are asking a 1st semester student type of question. If you are then attempting to write an MFC program is way beyond your current level of knowledge. Get an introduction to computer programming book and start studying from page 1. Then in a year or so you will be ready for that MFC program.

Can i know what's wrong with the below source code? can i put the variable x, y like this? How it can't work?

#include <Windows.h>
#include <mmsystem.h>
#pragma comment (lib,"winmm.lib")

int ,x,y;
void CTestingDlg::OnPlay() 
{
	// TODO: Add your control notification handler code here
			
                UpdateData(TRUE);

	CString strFreq;
	CString strHL;

	strFreq = m_strFreq;
	strHL = m_strHL;
	
	strFreq.MakeUpper();
	strHL.MakeUpper();

	if(strFreq=="x" && strHL=="y")
		   PlaySound("x_y_2.wav",NULL,SND_FILENAME);

}

a ) CString to int :

CString csNumber = "3";
int x;
x = atoi(csNumber); //defined in <cstdlib>


b) int to CString

int x = 23;
CString csNumber;
csNumber.format("%d", x);

This will do .....

Make urself comfortable with basic C++ before moving into MFC ....

You have an extra comma (',') before the x... Is that your question, and is that even a problem?

I think the address befor var may be the reason

int ,x,y;

Delete the comma.

strFreq.MakeUpper();
strHL.MakeUpper();

if(strFreq=="x" && strHL=="y")

You made those strings into upper-case and then you compare it with lower-case string.

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.