vb.net画爱心代码 vb绘制爱心
VB绘心形图源代码
放入一个按钮复制下面代码即可
创新互联公司服务项目包括息县网站建设、息县网站制作、息县网页制作以及息县网络营销策划等。多年来,我们专注于互联网行业,利用自身积累的技术优势、行业经验、深度合作伙伴关系等,向广大中小型企业、政府机构等提供互联网行业的解决方案,息县网站推广取得了明显的社会效益与经济效益。目前,我们服务的客户以成都为中心已经辐射到息县省份的部分城市,未来相信会继续扩大服务区域并继续获得客户的支持与信任!
Private Sub Command1_Click()
Print "/\/\"
Print "\ /"
Print " \/"
End Sub
用VB程序怎么做一个心型图?
Dim X1, Y1, X2, Y2 As Integer
Dim I As Integer
Dim J As Boolean
Dim K As IntegerDim WithEvents Label1 As Label
Dim WithEvents Timer1 As TimerPrivate Sub Form_Activate()
I = 100
K = 100
X1 = Me.Width / 2
Y1 = Me.Height / 3
X2 = X1
Y2 = Y1
Label1.Top = Me.Height / 2 - Label1.Height / 2
Label1.Left = Me.Width / 2 - Label1.Width / 2
End SubPrivate Sub Form_Load() Me.BackColor = H0
Me.FillColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
Me.ForeColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
Me.DrawMode = 13
Me.DrawWidth = 2
Me.FillStyle = 7
Set Label1 = Me.Controls.Add("VB.Label", "Label1")
Set Timer1 = Me.Controls.Add("VB.Timer", "Timer1")
Label1.Visible = True
Label1.AutoSize = True
Label1.BackStyle = 0
Label1.Caption = "I LOVE YOU"
Label1.Font.Size = 60
Label1.ForeColor = HFF00
Timer1.Enabled = True
Timer1.Interval = 10
Me.WindowState = 2
End SubPrivate Sub Timer1_Timer()
Me.Circle (X1, Y1), 250
Me.Circle (X2, Y2), 250
If Y1 = Me.Height - 1200 Then
X1 = X1 + K
Y1 = Y1 - I
X2 = X2 - K
Y2 = Y2 - I
I = I - 2
If Y1 = Me.Height / 3 Then
K = K - 1
ElseIf Y1 = Me.Height / 3 Then
K = K - 5
End If
Else
I = 100
K = 100
X1 = Me.Width / 2
Y1 = Me.Height / 3
X2 = X1
Y2 = Y1
Me.FillColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255)
Me.ForeColor = RGB(Rnd * 255, Rnd * 255, Rnd * 255) End If
Me.DrawWidth = 3
Me.PSet (Rnd * Me.Width, Rnd * Me.Height), RGB(Rnd * 225, Rnd * 225, Rnd * 225)
Me.DrawWidth = 2
End SubPrivate Sub Form_Click()
End
End SubPrivate Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
End
End Sub
如何用VB.NET画同心圆
窗体上添加一个按钮,在该按钮的单击事件里编写代码如下:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'声明窗体的Me.CreateGraphics对象
Dim MyGraphics As Graphics = Me.CreateGraphics
Dim Cx As Integer = 150 '圆心的X坐标
Dim Cy As Integer = 150 '圆心的Y坐标
Dim R As Integer '圆的半径
'绘制半径为R的圆
For R = 5 To 100 Step 5
MyGraphics.DrawEllipse(Pens.Black, New Rectangle(Cx - R, Cy - R, 2 * R, 2 * R))
Next
End Sub
‘用黑色画笔绘制一组同心圆,半径从5开始,增量为5。
说明:
DrawEllipse是VB.Net的Graphics类的绘制椭圆的方法;他有几种格式,上面使用的是一种;
DrawEllipse(画笔的颜色,绘制椭圆所需要的矩形区域)
其中:绘制椭圆所需要的矩形区域,如果被定义为正方形,就演变成绘制圆,定义该区域由死个数值确定,第1个数值,确定该区域左上角的X坐标,第2个数值,确定该区域左上角的Y坐标,第3个数值,确定该区域的宽度,第4个数值,确定该区域的高度。
例如1:
DrawEllipse(Pens.Black, New Rectangle(150, 150, 50, 50))
就是以圆心坐标为(100,100),绘制半径为50 的圆。其实在VB.NET中,是告诉系统在以左上角坐标(150,150),边长为50的正方形里绘制内切圆。理解了是在正方形里绘制内切圆,就可以通过数学计算,知道如何绘制了。
同理例如2:
DrawEllipse(Pens.Black, New Rectangle(150, 150, 100, 50))
就是以圆心坐标为(100,100),绘制半径为50 的圆。其实在VB.NET中,是告诉系统在以左上角坐标(150,150),长轴为100,短轴为50的内切椭圆。
VB编写爱心形状的窗体
你的描述我不是很明白,可以给你个思路!首先找个爱心形状的图片,加载进窗体的picturebox中,调整到合适大小。然后用以下让窗体透明。'设置Me.BorderStyle = 0
Private Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Private Const WS_EX_LAYERED = H80000
Private Const GWL_EXSTYLE = (-20)
Private Const LWA_ALPHA = H2
Private Const LWA_COLORKEY = H1
Private Declare Function ReleaseCapture Lib "user32" () As Long
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_NCLBUTTONDOWN = HA1
Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Private Sub Form_Load()
Me.BackColor = HFF0000
Dim rtn As Long
rtn = GetWindowLong(hwnd, GWL_EXSTYLE)
rtn = rtn Or WS_EX_LAYERED
SetWindowLong hwnd, GWL_EXSTYLE, rtn
SetLayeredWindowAttributes hwnd, HFF0000, 0, LWA_COLORKEY
End Sub
当前名称:vb.net画爱心代码 vb绘制爱心
浏览地址:http://ybzwz.com/article/dopdcpo.html