-
February 17th, 2014, 11:22 PM
#1
If else statement Question
Hello,
I'm trying to figure out how to make this work. I do not know what would be a better fit to help me with this code.
if (OSVersionInfo.ServicePack != string.Empty)
//sb.AppendLine(String.Format("Service Pack = {0}", OSVersionInfo.ServicePack));
label30.Text = String.Format("Service Pack = {0}", OSVersionInfo.VersionString);
label30.BackColor = Color.White;
label30.ForeColor = Color.Green;
else
//sb.AppendLine("Service Pack = None");
label30.Text = String.Format("Service Pack = {0}", OSVersionInfo.VersionString);
label30.BackColor = Color.White;
label30.ForeColor = Color.Green;
I need to be able to only check for 1 condition, but once found, exeute the code with 3 lines.
If I cannot do it with the If Else code, can you please point me in the write direction.
Thanks,
-
February 18th, 2014, 12:08 AM
#2
Re: If else statement Question
Dim a Flag as Boolean. Set it to FALSE. Check the condition, and run the code (which would add the Version)
-
February 18th, 2014, 01:11 AM
#3
Re: If else statement Question
If you are coding in C#, you need to add braces around the if and else statements.
Code:
if (OSVersionInfo.ServicePack != string.Empty)
{
//sb.AppendLine(String.Format("Service Pack = {0}", OSVersionInfo.ServicePack));
label30.Text = String.Format("Service Pack = {0}", OSVersionInfo.VersionString);
label30.BackColor = Color.White;
label30.ForeColor = Color.Green;
}
else
{
//sb.AppendLine("Service Pack = None");
label30.Text = String.Format("Service Pack = {0}", OSVersionInfo.VersionString);
label30.BackColor = Color.White;
label30.ForeColor = Color.Green;
}
-
February 18th, 2014, 11:11 PM
#4
Re: If else statement Question
Thanks Arjay,
That helped me.
Mike
Originally Posted by Arjay
If you are coding in C#, you need to add braces around the if and else statements.
Code:
if (OSVersionInfo.ServicePack != string.Empty)
{
//sb.AppendLine(String.Format("Service Pack = {0}", OSVersionInfo.ServicePack));
label30.Text = String.Format("Service Pack = {0}", OSVersionInfo.VersionString);
label30.BackColor = Color.White;
label30.ForeColor = Color.Green;
}
else
{
//sb.AppendLine("Service Pack = None");
label30.Text = String.Format("Service Pack = {0}", OSVersionInfo.VersionString);
label30.BackColor = Color.White;
label30.ForeColor = Color.Green;
}
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|