Convert C# to vb.net help

S

scorpion53061

(IT is saying the Operator '=' is not defined for types
'System.Drawing.Color' and 'System.Drawing.Color'.

(btnface is a color)



If btnFace = Color.White OrElse btnFace = Color.Black Then

res = highlight

Else

res = Color.FromArgb(GetLightIndex(colorInfo1,
btnFace.R, highlight.R, window.R), GetLightIndex(colorInfo1, btnFace.G,
highlight.G, window.G), GetLightIndex(colorInfo1, btnFace.B,
highlight.B, window.B))

End If







It is saying the Public Event Changed(sender As Object, e As
System.EventArgs)' is an event, and cannot be called directly. Use a
'RaiseEvent' statement to raise an event.



Protected Overridable Sub OnChanged()

If Not (Changed) Is Nothing Then

RaiseEvent Changed(Me, EventArgs.Empty)

End If

End Sub 'OnChanged





Thank you for any help!!
 
C

Cor Ligthert

Scorpion,

Convert it first to argb that goes forerver, a piece of code Peter Huang
showed recently in this newsgroup.


Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim kc As Color = Color.FromKnownColor(KnownColor.Blue)
Dim cr As Color = Color.FromArgb(kc.ToArgb())
Dim c As KnownColor
For i As Integer = 1 To 137
If Color.FromKnownColor(i).ToArgb() = cr.ToArgb() Then
Debug.WriteLine(CType(i, KnownColor).ToString())
End If
Next
End Sub

Cor
 
H

Herfried K. Wagner [MVP]

* "scorpion53061 said:
(IT is saying the Operator '=' is not defined for types
'System.Drawing.Color' and 'System.Drawing.Color'.

(btnface is a color)



If btnFace = Color.White OrElse btnFace = Color.Black Then

'If btnFace.Equals(Color.White OrElse...'.
It is saying the Public Event Changed(sender As Object, e As
System.EventArgs)' is an event, and cannot be called directly. Use a
'RaiseEvent' statement to raise an event.



Protected Overridable Sub OnChanged()

If Not (Changed) Is Nothing Then

RaiseEvent Changed(Me, EventArgs.Empty)

End If

End Sub 'OnChanged

Remove the 'If Not (Changed)' Is Nothing...' stuff. VB.NET will do the
checking for you.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top