也容易,如果是黑白三个颜色加上相同的渐变量,彩色的是起始颜色的三个分量与终止颜色的对应三个分量的差值,再除于相同的份数,就得出三原色各自的步进量。
让客户满意是我们工作的目标,不断超越客户的期望值来自于我们对这个行业的热爱。我们立志把好的技术通过有效、简单的方式提供给客户,将通过不懈努力成为客户在信息化领域值得信任、有价值的长期合作伙伴,公司提供的服务项目有:申请域名、虚拟主机、营销软件、网站建设、海丰网站维护、网站推广。
窗体上放个图片框试试下面代码:
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
Dim startColor As Color = Color.Red
Dim endColor As Color = Color.Green
Dim s As String = "vb.net 如何使文字能渐变颜色,就是颜色慢慢变淡然后在慢慢恢复?"
Dim Steps As Integer = s.Length \ 2
Dim StepR As Integer = (CInt(endColor.R) - startColor.R) \ Steps
Dim StepG As Integer = (CInt(endColor.G) - startColor.G) \ Steps
Dim StepB As Integer = (CInt(endColor.B) - startColor.B) \ Steps
Dim R As Integer = startColor.R
Dim G As Integer = startColor.G
Dim B As Integer = startColor.B
Dim drawFont As New System.Drawing.Font("Arial", 16)
Dim X As Integer = 50
For i As Integer = 1 To Steps
Dim drawBrush As New SolidBrush(Color.FromArgb(R, G, B))
e.Graphics.DrawString(s.Substring(i - 1, 1), drawFont, drawBrush, X, 50.0)
X += 18
R += StepR
G += StepG
B += StepB
Next
For i As Integer = 1 To Steps
Dim drawBrush As New SolidBrush(Color.FromArgb(R, G, B))
e.Graphics.DrawString(s.Substring(i + Steps - 1, 1), drawFont, drawBrush, X, 50.0)
X += 18
R -= StepR
G -= StepG
B -= StepB
Next
End Sub
可以利用font 设置。设置方法如下:
TextBox1.Font = New System.Drawing.Font("宋体", 10)
也可以通过字体对话框来实现 如:
Private Sub myButton_Click(sender As Object, e As EventArgs)
Dim myFontDialog As FontDialog
myFontDialog = New FontDialog()
If myFontDialog.ShowDialog() = DialogResult.OK Then
' Set the control's font.
myDateTimePicker.Font = myFontDialog.Font
End If
End Sub
这个问题的本质就是随机二字,无论c/s还是b/s里面的label1 ,只要随机设置字体颜色属性即可。而相关属性我相信您肯定知道,关键是怎样随机。vb.net里面有一个随机函数,只要利用该随机函数,随机生成相应的颜色即可,然后把随机颜色赋值给label的属性
首先command的style要设为1,否则无法改变
然后在backcolor设置颜色
按钮的字体颜色不能改
如果想改字体颜色,简单点可以用image做按钮。
如果一定要,请看:
在工程中添加以下模块(Module):
Module modExtButton.bas
Option Explicit