BrijBhasin
asked on
convert code from C# to VB
Hi,
I'm on a tight deadline and would appreaciate if someone can convert the following code from C# to VB.
Thanks
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
KnownColor enumColor = new KnownColor();
Array Colors = Enum.GetValues(enumColor.G etType());
ArrayList ALColor = new ArrayList();
foreach(object clr in Colors)
if (!Color.FromKnownColor((Kn ownColor)c lr).IsSyst emColor)
ALColor.Add(clr.ToString() );
cboColor.DataSource = ALColor;
cboColor.DataBind();
}
for (int i= 0 ;i < cboColor.Items.Count;i++)
{
cboColor.Items[i].Attribut es.Add("st yle", "color:" + cboColor.Items[i].Text);
}
}
private void cboColor_ServerChanged(obj ect sender, System.EventArgs e)
{
if (cboColor.SelectedIndex > -1)
strSelectedColor = cboColor.Items[cboColor.Se lectedInde x].Text;
else
strSelectedColor = cboColor.Items[0].Text;
}
I'm on a tight deadline and would appreaciate if someone can convert the following code from C# to VB.
Thanks
private void Page_Load(object sender, System.EventArgs e)
{
if (!IsPostBack)
{
KnownColor enumColor = new KnownColor();
Array Colors = Enum.GetValues(enumColor.G
ArrayList ALColor = new ArrayList();
foreach(object clr in Colors)
if (!Color.FromKnownColor((Kn
ALColor.Add(clr.ToString()
cboColor.DataSource = ALColor;
cboColor.DataBind();
}
for (int i= 0 ;i < cboColor.Items.Count;i++)
{
cboColor.Items[i].Attribut
}
}
private void cboColor_ServerChanged(obj
{
if (cboColor.SelectedIndex > -1)
strSelectedColor = cboColor.Items[cboColor.Se
else
strSelectedColor = cboColor.Items[0].Text;
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
BrijBhasin,
Here's a link that will allow you to paste C# code and it will convert it to VB.NET:
http://authors.aspalliance.com/aldotnet/examples/translate.aspx
HtH.
Here's a link that will allow you to paste C# code and it will convert it to VB.NET:
http://authors.aspalliance.com/aldotnet/examples/translate.aspx
HtH.
Private Sub Page_Load(sender As Object, e As System.EventArgs)
If Not IsPostBack Then
Dim enumColor As New KnownColor()
Dim Colors As Array = [Enum].GetValues(enumColor
Dim ALColor As New ArrayList()
Dim clr As Object
For Each clr In Colors
If Not Color.FromKnownColor(CType
ALColor.Add(clr.ToString()
End If
Next clr
cboColor.DataSource = ALColor
cboColor.DataBind()
End If
Dim i As Integer
For i = 0 To cboColor.Items.Count - 1
cboColor.Items(i).Attribut
Next i
End Sub 'Page_Load
Private Sub cboColor_ServerChanged(sen
If cboColor.SelectedIndex > - 1 Then
strSelectedColor = cboColor.Items(cboColor.Se
Else
strSelectedColor = cboColor.Items(0).Text
End If
End Sub 'cboColor_ServerChanged
Why didn't you use
"If Not Color.FromKnownColor(clr). IsSystemCo lor Then"
like in the code I posted?
"If Not Color.FromKnownColor(clr).
like in the code I posted?
ASKER
jensfiederer I didnt see your post when I posted my comment, it was meant for Chaosian. I'm splitting the points and giving you both credit.
ASKER
on:
If Not CType(clr, Color).IsSystemColor Then