优秀的编程知识分享平台

网站首页 > 技术文章 正文

福彩双色球幻圆图的VBA程序(第一部分)

nanyue 2024-12-19 15:28:33 技术文章 5 ℃

很多朋友喜欢玩福彩双色球彩票,都知道下面的这张图——福彩双色球红球幻圆图和篮球幻方图。

图2是福彩双色球2024104期(红色)和2024105期(黄色)的幻圆图。

图3是福彩双色球2024105期(红色)和2024106期(黄色)的幻圆图。

图4是福彩双色球2024106期(红色)和2024107期(白色,未开奖)的幻圆图。

下面,我们详细介绍VBA+EXCEL制作幻圆图的过程并得出相应的vba程序。

第一步,画出米字型直线和圆环

1、新建一个Excel空白工作簿,另存为“启用宏的工作簿”,文件名用自己喜欢的。

2、点击“开发工具”,点击“设计模式”,点击”插入“,选择ActiveX控件中的按钮控件两个。

3、复制如下代码到名为CommandButton1按钮的Click事件中。

Dim shapeCount As Integer

Dim i As Integer

'批量画直线

For i = 1 To 4

ActiveSheet.Shapes.AddConnector(msoConnectorStraight, 120, 150, 360, 150). _

Select

'将形状重命名为"Line" & i

Selection.Name = "Line" & i

Selection.ShapeRange.Rotation = (i - 1) * 45

Application.CommandBars("Format Object").Visible = False

'设置形状边框颜色——黑色

With Selection.ShapeRange.Line

.Visible = msoTrue

.ForeColor.RGB = RGB(0, 0, 0)

.Transparency = 0

End With

Next i

'批量画圆

shapeCount = 4

For i = 1 To shapeCount

'在活动工作表上添加新的形状—msoShapeOval(圆形)

ActiveSheet.Shapes.AddShape(msoShapeOval, 210 + (1 - i) * 30, 120 + (1 - i) * 30, 60 * i, 60 * i).Select

'将形状重命名为"Round " & i

Selection.Name = "Round " & i

'设置形状边框颜色——黑色

With Selection.ShapeRange.Line

.Visible = msoTrue

.ForeColor.RGB = RGB(0, 0, 0)

.Transparency = 0

End With

'填充形状颜色——白色

With Selection.ShapeRange.Fill

.Visible = msoFalse

End With

Next i

4、关闭“设计模式”,点击保存文件,点击CommandButton1按钮,运行结果如下图。

5、复制如下代码到名为CommandButton2按钮的Click事件中。

Dim shapeCount As Integer

Dim i As Integer

'设置要创建的形状数量33个

shapeCount = 33

For i = 1 To shapeCount

'在活动工作表上添加新的形状—msoShapeOval(圆形)

ActiveSheet.Shapes.AddShape(msoShapeOval, 100 + (i - 1) * 10, 100 + (i - 1), 20, 20).Select

'将形状重命名为"redball" & i

Selection.Name = "redball" & i

'填充数字1至33

Selection.ShapeRange.TextFrame2.TextRange.Characters.Text = i

Selection.ShapeRange.TextFrame2.VerticalAnchor = msoAnchorMiddle

Selection.ShapeRange.TextFrame2.TextRange.ParagraphFormat.Alignment = msoAlignCenter

Selection.ShapeRange.TextFrame2.WordWrap = msoFalse

'填充字体颜色——黑色

With Selection.ShapeRange.TextFrame2.TextRange.Font.Fill

.Visible = msoTrue

.ForeColor.RGB = RGB(0, 0, 0)

.Transparency = 0

.Solid

End With

'设置形状边框颜色——黑色

With Selection.ShapeRange.Line

.Visible = msoTrue

.ForeColor.RGB = RGB(0, 0, 0)

.Transparency = 0

End With

'填充形状颜色——白色

With Selection.ShapeRange.Fill

.Visible = msoTrue

.ForeColor.RGB = RGB(255, 255, 255)

.Transparency = 0

.Solid

End With

Next i

6、关闭“设计模式”,点击保存文件,点击CommandButton2按钮,运行结果如下图。

7、手动移动有编号的红球到米字型直线与圆环的交叉点的相应位置上。

如红球33所放置的位置。

下一篇,我们将讲如何根据历史数据动态显示双色球幻圆图,也就是福彩双色球幻圆图的VBA程序(第二部分)。

最近发表
标签列表