如何将vb6转换为vb.net?请帮忙..
问题描述:
Private Sub Command1_Click()
Dim NamaFile As String
Me.CommonDialog1.ShowOpen
NamaFile = Me.CommonDialog1.FileName
Picture1.Picture = LoadPicture(NamaFile)
End Sub
Private Sub Command2_Click()
On Error Resume Next
Dim ib, r, g, b As Double
For i = 0 To Picture1.ScaleWidth
For j = 0 To Picture1.ScaleHeight
warna = Picture1.Point(i, j)
r = warna And RGB(255, 0, 0) 'merah
g = warna \ 256 And &HFF 'hijau
b = warna \ 256 ^ 2 And RGB(0, 0, 256) / 256 / 256 'biru
greyscale = CInt((r + g + b) / 3)
bagi = (2 * (((r - a) ^ 2) + ((r - b) * (g - r))) ^ 0.5)
If bagi = 0 Then bagi = 1
cosh = ((2 * r) - g - b) / bagi
If cosh = 0 Then cosh = 1
tangenh = ((1 - ((cosh) ^ 2)) ^ 0.5) / cosh
hue = Atn(tangenh)
If hue < 255 Then hue = hue + 360
ib = b / (r + g + b)
If r > 100 And g > 40 And b > 170 Then
'If (greyscale < 170 And ib < 3) Or r < 130 Then
' pixel(i, j) = 0
Picture1.PSet (i, j), RGB(0, 0, 0)
warna = 0
'End If
Else
n = n + 1
' pixel(i, j) = 1
Picture1.PSet (i, j), RGB(r, g, b)
'Picture1.PSet (i, j), RGB(255, 255, 255)
jumr = jumr + r
jumb = jumb + b
jumg = jumg + g
End If
'piks(i, j) = warna
Next j
Next i
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
On Error Resume Next
warna = Picture1.Point(X, Y)
r = warna And &HFF
g = warna \ 256 And &HFF
b = warna \ 256 ^ 2 And &HFF
gs = (r + g + b) / 3
greyscale = CInt((r + g + b) / 3)
bagi = (2 * (((r - a) ^ 2) + ((r - b) * (g - r))) ^ 0.5)
If bagi = 0 Then bagi = 1
cosh = ((2 * r) - g - b) / bagi
If cosh = 0 Then cosh = 1
tangenh = ((1 - ((cosh) ^ 2)) ^ 0.5) / cosh
hue = Atn(tangenh)
NilaiHiu.Text = hue
TxtR.Text = r / (r + g + b)
TxtG.Text = g / (r + g + b)
TxtB.Text = b / (r + g + b)
Text4.Text = r
Text5.Text = g
Text6.Text = b
Text7.Text = gs
End Sub
答
更糟糕的提示是显示转换器集 [ ^ ]。请阅读类似讨论 [ ^ ]查找原因。
最佳提示你是由Wes Aday制定的。您需要了解代码的作用,而不是使用VB.NET对象,方法等重新编写代码。
The worse hint for you is to show the set of converters[^]. Please, read similar discussion[^] for find out why.
The best hint for you was formulated by Wes Aday. You need to understand what code does, than to re-write it using VB.NET objects, methods, etc.