vb.net颜色代码 vb中颜色的代码大全

VB.NET设置屏幕分辨率、颜色位数、刷新率 实例代码这篇文章介绍了VB.NET设置屏幕分辨率、颜色位数、刷新率
实例代码,有需要的朋友可以参考一下
复制代码
代码如下:
Private
Declare
Function
GetDeviceCaps
Lib
"gdi32"
(ByVal
hdc
As
Long,
ByVal
nIndex
As
Long)
As
Long
Private
Declare
Function
ChangeDisplaySettings
Lib
"user32"
Alias
"ChangeDisplaySettingsA"
(lpDevMode
As
Any,
ByVal
dwflags
As
Long)
As
Long
Private
Const
CCDEVICENAME
As
Long
=
32
Private
Const
CCFORMNAME
As
Long
=
32
Private
Const
DM_BITSPERPEL
As
Long
=
H40000
Private
Const
DM_PELSWIDTH
As
Long
=
H80000
Private
Const
DM_PELSHEIGHT
As
Long
=
H100000
Private
Const
DM_DISPLAYFLAGS
As
Long
=
H200000
Private
Const
DM_DISPLAYFREQUENCY
=
H400000
Private
Const
CDS_FORCE
As
Long
=
H80000000
Private
Const
BITSPIXEL
As
Long
=
12
Private
Const
HORZRES
As
Long
=
8
Private
Const
VERTRES
As
Long
=
10
Private
Const
VREFRESH
=
116
Private
Type
DEVMODE
dmDeviceName
As
String
*
CCDEVICENAME
dmSpecVersion
As
Integer
dmDriverVersion
As
Integer
dmSize
As
Integer
dmDriverExtra
As
Integer
dmFields
As
Long
dmOrientation
As
Integer
dmPaperSize
As
Integer
dmPaperLength
As
Integer
dmPaperWidth
As
Integer
dmScale
As
Integer
dmCopies
As
Integer
dmDefaultSource
As
Integer
dmPrintQuality
As
Integer
dmColor
As
Integer
dmDuplex
As
Integer
dmYResolution
As
Integer
dmTTOption
As
Integer
dmCollate
As
Integer
dmFormName
As
String
*
CCFORMNAME
dmUnusedPadding
As
Integer
dmBitsPerPel
As
Integer
dmPelsWidth
As
【vb.net颜色代码 vb中颜色的代码大全】Long
dmPelsHeight
As
Long
dmDisplayFlags
As
Long
dmDisplayFrequency
As
Long
End
Type
Private
Sub
cmdChangeDesktopMode_Click()
Dim
DM
As
DEVMODE
With
DM
.dmPelsWidth
=
CInt(txtNewWidth.Text)
.dmPelsHeight
=
CInt(txtNewHeight.Text)
.dmBitsPerPel
=
CInt(txtNewColor.Text)
.dmDisplayFrequency
=
CInt(txtNewFreq.Text)
.dmFields
=
DM_PELSWIDTH
Or
DM_PELSHEIGHT
Or
DM_BITSPERPEL
Or
DM_DISPLAYFREQUENCY
.dmSize
=
LenB(DM)
End
With
If
ChangeDisplaySettings(DM,
CDS_FORCE)
Then
MsgBox
"错误!不支持此模式!"
End
If
End
Sub
Private
Sub
Form_Load()
txtOldWidth.Text
=
GetDeviceCaps(Me.hdc,
HORZRES)
txtOldHeight.Text
=
GetDeviceCaps(Me.hdc,
VERTRES)
txtOldColor.Text
=
GetDeviceCaps(Me.hdc,
BITSPIXEL)
txtOldFreq.Text
=
GetDeviceCaps(Me.hdc,
VREFRESH)
End
Sub
在vb.net中,如何获取Graphics中某一指定点(像素)的颜色值?(VB语言)要使用GetPixel函数来取得像素的颜色值,代码如下:
1
2
3
4
5
private void button1_Click(object sender, EventArgs e)
{
Color color = new Bitmap(pictureBox1.Image).GetPixel(10, 10);
MessageBox.Show(color.ToString());
在vb 。net中 我们制作个打字程序我想在文本框里的字母中指定一个字母变颜色的代码,要怎么写??在TextChanged事件中:privatevoidrichTextBox1_TextChanged(objectsender,EventArgse)
{
if(label1.Text==richTextBox1.Text)
richTextBox1.ForeColor=Color.Black;
else
richTextBox1.ForeColor=Color.Red;
}-------------------继续答复:
首先,还是建议你使用TextChange方法 。KeyPress方法只有在松开键后才触发,如果一直按着键比如写a,那这串a颜色不会变的,直到你松手 。
然后上代码,测试可用的,你直接放到KeyPress里也能用:
PrivateSubrichTextBox1_TextChanged(senderAsObject,eAsEventArgs)
ForiAsInteger=0TorichTextBox1.TextLength-1
richTextBox1.SelectionStart=i
richTextBox1.SelectionLength=1
Ifi=label1.Text.LengthThen
richTextBox1.SelectionColor=Color.Blue
ElseIflabel1.Text(i)richTextBox1.Text(i)Then
richTextBox1.SelectionColor=Color.Red
Else
richTextBox1.SelectionColor=Color.Black
EndIf
Next
richTextBox1.SelectionLength=0
richTextBox1.SelectionStart=richTextBox1.TextLength
EndSub这里写错的是红色 , 多写出来的是蓝色,具体你自己可以调整 。
顺便鄙视一下那个把我代码直接转VB贴上来的 , 我直接用工具转成VB了,方便楼主参考 。
有问题可以继续追问 。
vb.net复选框及字体颜色问题 题目是图上的第十题,计算代码我会做,但是那个红字黄底的代码怎么写TextBox1.ForeColor = Color.Red
TextBox1.BackColor = Color.Yellow
TextBox1.Text = 1234
关于vb.net颜色代码和vb中颜色的代码大全的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站 。

    推荐阅读