Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Bypass switch statment

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
In the below code I want to be able to bypass the switch statment when the following condition is met, (MaskEdit1->Text==" : ") . Could I put another case statment testing for " : " then break. Something like, case " : ": break; But how do I make a DWORD = " : "; ???


void __fastcall TForm1::MaskEdit1Exit(TObject *Sender)
{

const TDateTime HKoffsetStandard = TDateTime(8, 0, 0, 0);

TIME_ZONE_INFORMATION tzi2;
DWORD rValue2;

if(MaskEdit1->Text==" : ") //thinking of putting this statment here but then what??????


TDateTime dtTime = StrToTime(MaskEdit1->Text);
rValue2 = GetTimeZoneInformation((LPTIME_ZONE_INFORMATION) &tzi2);


switch (rValue2)
{
case TIME_ZONE_ID_UNKNOWN:
{

Label9->Caption="ERROR3..";
break;
}
case TIME_ZONE_ID_STANDARD:
{
TDateTime dt;
try
{
MaskEdit2->Text=FormatDateTime("hh:mm", dtTime+HKoffsetStandard);


}
catch(...)
{
Application->MessageBox("Invalid hour, minute.", "ATZ Calculator", MB_OK);

}
break;
}
case TIME_ZONE_ID_DAYLIGHT:
{
TDateTime dt;
try
{
MaskEdit2->Text=FormatDateTime("hh:mm", dtTime+HKoffsetDaylight);


}
catch(...)
{
Application->MessageBox("Invalid hour, minute.", "mtprog", MB_OK);
}

break;
}
default:
Label9->Caption="ERROR4..";

break;
}

}
 
Greetinx!

An example, you cam write like follows:
TDateTime dtTime;
if(MaskEdit1->Text==" : ")
rValue2 = TIME_ZONE_ID_UNKNOWN;
//or any other error type you defined
else
{
dtTime = StrToTime(MaskEdit1->Text);
rValue2 = GetTimeZoneInformation((LPTIME_ZONE_INFORMATION) &tzi2);
}


Happy programming!))
 
if(!(MaskEdit1->Text==" : "))
{

switch (rValue2)
{
case TIME_ZONE_ID_UNKNOWN:
{

Label9->Caption="ERROR3..";
break;
}
case TIME_ZONE_ID_STANDARD:
{
TDateTime dt;
try
{
MaskEdit2->Text=FormatDateTime("hh:mm", dtTime+HKoffsetStandard);


}
catch(...)
{
Application->MessageBox("Invalid hour, minute.", "ATZ Calculator", MB_OK);

}
break;
}
case TIME_ZONE_ID_DAYLIGHT:
{
TDateTime dt;
try
{
MaskEdit2->Text=FormatDateTime("hh:mm", dtTime+HKoffsetDaylight);


}
catch(...)
{
Application->MessageBox("Invalid hour, minute.", "mtprog", MB_OK);
}

break;
}
default:
Label9->Caption="ERROR4..";

break;
}

}// end if


Matt
 
There is also the horrible &quot;goto&quot; >:-< statement


EEEK

Matt
 
if you missed the ! in the first post i made, the if is the same as:

if((MaskEdit1->Text != &quot; : &quot;))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top