Private?Sub?Command1_Click()
公司主營(yíng)業(yè)務(wù):網(wǎng)站設(shè)計(jì)、成都網(wǎng)站設(shè)計(jì)、移動(dòng)網(wǎng)站開(kāi)發(fā)等業(yè)務(wù)。幫助企業(yè)客戶(hù)真正實(shí)現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競(jìng)爭(zhēng)能力。創(chuàng)新互聯(lián)公司是一支青春激揚(yáng)、勤奮敬業(yè)、活力青春激揚(yáng)、勤奮敬業(yè)、活力澎湃、和諧高效的團(tuán)隊(duì)。公司秉承以“開(kāi)放、自由、嚴(yán)謹(jǐn)、自律”為核心的企業(yè)文化,感謝他們對(duì)我們的高要求,感謝他們從不同領(lǐng)域給我們帶來(lái)的挑戰(zhàn),讓我們激情的團(tuán)隊(duì)有機(jī)會(huì)用頭腦與智慧不斷的給客戶(hù)帶來(lái)驚喜。創(chuàng)新互聯(lián)公司推出懷仁免費(fèi)做網(wǎng)站回饋大家。
Print?"?**??????**"
Print?"****????****"
Print?"************"
Print?"?**********"
Print?"??********"
Print?"???******"
Print?"????****"
Print?"?????**"
End?Sub
'請(qǐng)參考采納!謝謝!
窗體上添加一個(gè)按鈕,在該按鈕的單擊事件里編寫(xiě)代碼如下:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
'聲明窗體的Me.CreateGraphics對(duì)象
Dim MyGraphics As Graphics = Me.CreateGraphics
Dim Cx As Integer = 150 '圓心的X坐標(biāo)
Dim Cy As Integer = 150 '圓心的Y坐標(biāo)
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
‘用黑色畫(huà)筆繪制一組同心圓,半徑從5開(kāi)始,增量為5。
說(shuō)明:
DrawEllipse是VB.Net的Graphics類(lèi)的繪制橢圓的方法;他有幾種格式,上面使用的是一種;
DrawEllipse(畫(huà)筆的顏色,繪制橢圓所需要的矩形區(qū)域)
其中:繪制橢圓所需要的矩形區(qū)域,如果被定義為正方形,就演變成繪制圓,定義該區(qū)域由死個(gè)數(shù)值確定,第1個(gè)數(shù)值,確定該區(qū)域左上角的X坐標(biāo),第2個(gè)數(shù)值,確定該區(qū)域左上角的Y坐標(biāo),第3個(gè)數(shù)值,確定該區(qū)域的寬度,第4個(gè)數(shù)值,確定該區(qū)域的高度。
例如1:
DrawEllipse(Pens.Black, New Rectangle(150, 150, 50, 50))
就是以圓心坐標(biāo)為(100,100),繪制半徑為50 的圓。其實(shí)在VB.NET中,是告訴系統(tǒng)在以左上角坐標(biāo)(150,150),邊長(zhǎng)為50的正方形里繪制內(nèi)切圓。理解了是在正方形里繪制內(nèi)切圓,就可以通過(guò)數(shù)學(xué)計(jì)算,知道如何繪制了。
同理例如2:
DrawEllipse(Pens.Black, New Rectangle(150, 150, 100, 50))
就是以圓心坐標(biāo)為(100,100),繪制半徑為50 的圓。其實(shí)在VB.NET中,是告訴系統(tǒng)在以左上角坐標(biāo)(150,150),長(zhǎng)軸為100,短軸為50的內(nèi)切橢圓。
放入一個(gè)按鈕復(fù)制下面代碼即可
Private Sub Command1_Click()
Print "/\/\"
Print "\ /"
Print " \/"
End Sub
Option Explicit
'類(lèi)型聲明
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
'API聲明
Private Declare Function BeginPath Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function TextOut Lib "gdi32" Alias "TextOutA" (ByVal hdc As Long, ByVal X As Long, ByVal Y As Long, ByVal lpString As String, ByVal nCount As Long) As Long
Private Declare Function EndPath Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function PathToRegion Lib "gdi32" (ByVal hdc As Long) As Long
Private Declare Function GetRgnBox Lib "gdi32" (ByVal hRgn As Long, lpRect As RECT) As Long
Private Declare Function CreateRectRgnIndirect Lib "gdi32" (lpRect As RECT) As Long
Private Declare Function CombineRgn Lib "gdi32" (ByVal hDestRgn As Long, ByVal hSrcRgn1 As Long, ByVal hSrcRgn2 As Long, ByVal nCombineMode As Long) As Long
Private Const RGN_AND = 1
Private Declare Function DeleteObject Lib "gdi32" (ByVal hObject As Long) As Long
Private Declare Function SetWindowRgn Lib "user32" (ByVal hwnd As Long, ByVal hRgn As Long, ByVal bRedraw As Boolean) As Long
Private Sub Form_Load()
Dim hRgn1, hRgn2 As Long
Dim rct As RECT
Dim rtn As Long
With Me
.BorderStyle = 0
.Caption = ""
.Font.Name = "Webdings" '設(shè)置字體
.Font.Size = 100
.Font.Bold = True
.BackColor = vbRed
.FontTransparent = True
End With
BeginPath hdc
'為窗體形狀產(chǎn)生路徑
TextOut hdc, 0, 0, "Y", 1 '字符Y的Webdings字體下是心形,1表示一個(gè)字節(jié)
EndPath hdc
hRgn1 = PathToRegion(hdc)
'將指定路徑轉(zhuǎn)換為區(qū)域
GetRgnBox hRgn1, rct
'獲取完全包含指定區(qū)域的最小矩形
hRgn2 = CreateRectRgnIndirect(rct)
'創(chuàng)建rct確定的矩形區(qū)域
CombineRgn hRgn2, hRgn2, hRgn1, RGN_AND
DeleteObject hRgn1
'刪除GDI對(duì)象,釋放占用的系統(tǒng)資源
SetWindowRgn hwnd, hRgn2, 1
End Sub
Private Sub Form_DblClick()
Unload Me
End Sub
Private Sub Form_Load()
Me.AutoRedraw = True
Me.Width = 5000
Me.Height = 5500
Me.ForeColor = vbRed
Me.FontSize = 12
Me.Scale (-10, 10)-(10, -10)
For i = 0 To 3.1415926 Step 0.2
CurrentX = -Cos(i) * 4 - 4
CurrentY = Sin(i) * 4 + 3
Print "*"
CurrentX = Cos(i) * 4 + 4
CurrentY = Sin(i) * 4 + 3
Print "*"
Next i
For i = 0 To 8 Step 0.5
CurrentX = 8 - i
CurrentY = -i + 2
Print "*"
CurrentX = i - 8
CurrentY = -i + 2
Print "*"
Next i
End Sub
首先你要準(zhǔn)備一個(gè)玫瑰花圖片文件,要小一點(diǎn)。
然后在窗體上放12個(gè)Image控件,組成一個(gè)控件數(shù)組,擺成心形,Picture屬性設(shè)置為你的玫瑰花。Visibel屬性全部設(shè)置為False。
在窗體上放一個(gè)Timer控件。Interval屬性設(shè)置為1000,每秒顯示一朵玫瑰花。
OK!你的心愿完成了!
Private Sub Form_Load()
For i = 0 To 11
Image1(i).Picture = LoadPicture(App.Path + "\西安綠博園七彩玫瑰.jpg")
Next
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Static i As Integer
Image1(i).Visible = True
i = i + 1
If i = Image1.Count Then
Label1.Visible = True
Timer1.Enabled = False
End If
End Sub