|
Hi
I have a C program that has three edit text boxes to enter the month, day and year. I also have an LTEXT field labeled Age. Is there a way that I can display the age after the month, day and year are entered. I have the program calculating the age but I cannot get it to display the age on the screen after the month day and year are entered.
Thanks
-- modified at 10:31 Monday 10th September, 2007
Marsha Eiter
|
|
|
|
|
If you're not using managed C++, then you're posting your question on the wrong board.
You should post on the Visual C++/MFC board.
eitwoman wrote: Is there a way to code the program that is a user enters the month, day or year instead of selecting it from the drop-down list that the system will automatically select the index of the month, day and year of the number that they entered?
Yes.
You could also look into using the Month Calendar Control[^].
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks I appreciate it but the user was pretty clear on wanting to be able to enter the data by hand.
I appreciate the suggestion though!
Marsha
Marsha Eiter
|
|
|
|
|
The SetWindowText() API can be used to set the text of the LTEXT control.
To convert a numeric age value to a string for display, you could use the CRT
sprintf_s() function.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Thanks I appreciate the help. I will try this and let you know.
Marsha
Marsha Eiter
|
|
|
|
|
char alpha[10] = "abcdefg";
string beta = "abcdefg";
alpha[1]= '\0'; gives the following result : alpha = a
beta[1]='\0'; gives the following result : beta = a cdefg
How can i use '\0' in strings as i use them in an array? I mean iwant that '\0' replace 'bcdefg' in string not just 'b'.
Thanks
|
|
|
|
|
#include<stdio.h>
void main()
{
char string1[10]="abcdef";
char string2[10]="abcdef";
string1[1]='\0';
string2[1]='\0';
printf("%s\n%s",string1,string2);
}
result:
a
a
----
i don't think it is wrong
ubri
|
|
|
|
|
Unfortunately, he is trying to modify a std::string and not a char array string.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Thanks for the tip
{
in a land with no bird, no spring. My first journey was a
return 0;
}
|
|
|
|
|
Apparently, you are printing the result with the following: std::cout << beta << std::endl . If you print it with std::cout << beta.c_str() << std::endl , you get the desired print out. However, if you actually want to remove the characters following 'a' you can do this:
#include <iostream>
#include <string>
int _tmain(int argc, _TCHAR* argv[])
{
std::string beta = "abcdefg";
beta.erase(beta.begin() + 1, beta.end());
std::cout << "Result #1: " << beta << std::endl;
std::cout << "Result #2: " << beta.c_str() << std::endl;
return 0;
}
Also, please post C++ questions in the C++ forum and not the C++/CLI forum.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
Hi.
Thanks for the tip.
Pourang
{
in a land with no bird, no spring. My first journey was a
return 0;
}
|
|
|
|
|
You are little bit consfused with char[] and std :: string
Please Clear about that.
Best Regards,
Chetan Patel
|
|
|
|
|
Hi.
I got my answer but you're right. I'm reading the c++ Primer + and there are different chapters to cover String. I did not read the chapter which explains in details.
It sucks to be a beginner
{
in a land with no bird, no spring. My first journey was a
return 0;
}
|
|
|
|
|
Hi, I am using Visual Studio 2005 C++/CLI. I want to print via the print preview dialog. I set up the printPreviewDialog and created a document I could view with the printPreviewDialog. But when I used the print button to print what was being displayed only some of the document was printed. The bottom of the document was cut off. I thought that the print preview dialog showed what the printed output would look like (WYSIWYG) before you decided to print it. Isn't this the case?
Buck
|
|
|
|
|
Here is the code snippet of my application. background thread is a managed thread.
Code Snippet
public ref class Form1 : public System::Windows::Forms::Form
{
private:
Thread^ myThread; //Managed Thread Handle
IDiscovery* discObj // Pointer to unmanaged type
public :
static System::Void ThreadProc(System::Object^ pv)
{
System::IntPtr^ ptrDiscovery = cli::safe_cast<system::intptr^>(pv);
IDiscovery *discObj;
discObj = (IDiscovery *)ptrDiscovery->ToPointer();
//get the list from IDiscovery
discObj->discoverList(false);
}//END OF THREADPROC
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
System::IntPtr^ pV = gcnew System::IntPtr(static_cast<void*>(discObj));
myThread = gcnew Thread(gcnew ParameterizedThreadStart(Form1::ThreadProc));
myThread->Start(pV);
}//END OF FUNCTION
At times I am getting following exception:
An unhandled exception of type 'System.AccessViolationException'
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
I am not sure whether this the right way to do it. Please suggest.
Thanks a lot,
Arti
|
|
|
|
|
art_ami wrote: 'System.AccessViolationException'
IDiscovery* discObj // Pointer to unmanaged type
is never initialized in the code you posted and could be the source of the error
|
|
|
|
|
It is initialized in the constructor. I just posted part of the Form1 class.
Also it works sometimes and sometimes I get this Exception
|
|
|
|
|
Hi, I am using Visual Studio 2005 C++/CLI. I am at the stage where I am rewriting the same application several different ways. This allows me to become more familiar and comfortable with the CLI syntax. In doing so there were a couple of Forms that had a lot of controls on them. Rather than re-create the Form and add all of the controls again I decided to used the Add->Existing Item command to add the Form information. Before adding I copied over the FormX.h, FormX.cpp and FormX.rex files into my current project directory, then I added them to the project. This works great except when I decided that I needed to modify the FormX[design]. I can't seem to get the FormX[design] window to open. Can someone tell me the correct procedure to add an existing Form from another project and then be able to modify the Form in the FormX[design] window?
Thanks
Buck
|
|
|
|
|
|
Sounds like you're asking a C++ question, which belongs in the Visual C++ forum. If you want to use .NET, this is the place to ask.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi Armond,
Armond Sarkisian wrote: I tried to research the cmd.exe command but it doesn't start a whole new window. Anyone can help on this?
does 'start cmd' the trick for you?
(type 'help start' to see the options of the start command)
greetings,
ralf.
|
|
|
|
|
call dos commmand.
"start"
ShellExecute(NULL,NULL,"cmd /c start",....)
|
|
|
|
|
using namespace std;
void one () {
error C2871: 'std' : does not exist or is not a namespace
: error C2601: 'one' : local function definitions are illegal
|
|
|
|
|
Did you include iostream without .h?
|
|
|
|
|
This is the C++/CLI forum, try the visual C++ forum for standard C++ questons.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|