简体   繁体   中英

Use Access VB.net to change background color of form control

I want to change the label's backgroundcolor so it gradually changes, but for some reason I can't use the RGB function. and my teacher isn't a real help cause he doesn't realy teach please help

Public Class Form1
Dim r, g, b As Integer

Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
    Timer1.Enabled = True

End Sub

Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    Timer1.Enabled = False

End Sub

Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
    r = 0
    g = 0
    b = 0

    For r = 1 To 225
        r += 1
        LblColor.BackColor = RGB(r, g, b)
    Next
    For g = 1 To 255
        g += 1
        LblColor.BackColor = RGB(r, g, b)
    Next
    For b = 1 To 255
        b += 1
        LblColor.BackColor = RGB(r, g, b)
    Next

End Sub

Private Function RGB(r As Integer, g As Integer, b As Integer) As Color

End Function

Private Sub LblColor_Click(sender As Object, e As EventArgs) Handles LblColor.Click

End Sub

End Class

The RGB() function is built-in to VBA. Try removing your own version -- it's prolly getting in the way.

Private Function RGB()...  '  |   
   ...                        |    <--- remove this bit
End Function                  |

恩,所以我发现对于VB.Net,我必须使用它: LblColor.BackColor = Color.FromArgb(r, g, b) ,现在它正在工作,感谢您的帮助

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM