用宏功能啊,然后把宏代碼(vb6.0)轉(zhuǎn)化為Vb.net代碼,有一個關(guān)鍵問題,就是VBA中的枚舉類型在Vb.net中不適用,比如.End(xlUp)更改為.End(3)就能運行,另外vb.net中運行Excel對象不一定在點后會出現(xiàn)智能提示(即使你引用后也一樣)你只要確定有該方法或者屬性,直接寫就是了,生成或者調(diào)試都是可以通過的
創(chuàng)新互聯(lián)公司2013年至今,是專業(yè)互聯(lián)網(wǎng)技術(shù)服務(wù)公司,擁有項目成都做網(wǎng)站、網(wǎng)站建設(shè)網(wǎng)站策劃,項目實施與項目整合能力。我們以讓每一個夢想脫穎而出為使命,1280元類烏齊做網(wǎng)站,已為上家服務(wù),為類烏齊各地企業(yè)和個人服務(wù),聯(lián)系電話:028-86922220
1. 建一個默認的project
2. 放一個command button
3. 放一個 200x200 pixel 的 Picture box
加入如下代碼:
Option Explicit
Public Sub DrawPiePiece(lColor As Long, fStart As Double, fEnd As
Double)
Const PI As Double = 3.14159265359
Const CircleEnd As Double = -2 * PI
Dim dStart As Double
Dim dEnd As Double
Picture1.FillColor = lColor
Picture1.FillStyle = 0
dStart = fStart * (CircleEnd / 100)
dEnd = fEnd * (CircleEnd / 100)
Picture1.Circle (100, 100), 60, , dStart, dEnd
End Sub
Private Sub Command1_Click()
Picture1.ScaleMode = vbPixels
Call DrawPiePiece(QBColor(1), 0.001, 36)
Call DrawPiePiece(QBColor(2), 36, 55)
Call DrawPiePiece(QBColor(3), 55, 75)
Call DrawPiePiece(QBColor(4), 75, 99.999)
End Sub
試一下吧
Dim MyGraphics As Graphics = Me.PictureBox1.CreateGraphics
Dim MyBrush As New SolidBrush(Color.Red)
Dim MyProportion As Single
Dim MyRect As New Rectangle
Dim MyPoint As New PointF
Dim R As Single
Const PI = 3.1415926
MyGraphics.Clear(Color.White)
Dim MyStartAngel As Double
Dim MySweepAngel As Double
R = Math.Min(Me.PictureBox1.Width, Me.PictureBox1.Height) / 2 - 15
MyPoint.X = Me.PictureBox1.Width / 2
MyPoint.Y = Me.PictureBox1.Height / 2
MyRect.X = MyPoint.X - R
MyRect.Y = MyPoint.Y - R
MyRect.Width = R * 2
MyRect.Height = R * 2
MyStartAngel = 0
MyProportion = Val(TextBox7.Text)
MySweepAngel = MyProportion * 360 / PI
MyBrush.Color = Color.Red
MyGraphics.FillPie(MyBrush, MyRect, MyStartAngel, MySweepAngel)
' MyStartAngel = MyStartAngel + MySweepAngel
MyProportion = 0.75
MySweepAngel = 360 * MyProportion
MyBrush.Color = Color.Blue
MyGraphics.FillPie(MyBrush, MyRect, MyStartAngel, MySweepAngel)
給你一個步驟吧.
設(shè)立一個圓心(即定一個點)
再按照用PI轉(zhuǎn)角來畫就行了.
最后加上你需要的顏色