首页 > 解决方案 > 在visual basic中创建一条线和圆

问题描述

我还没有找到正确的代码来画一条线和一个圆。

我尝试了 4 种不同的代码,但我遇到了变量和对象的问题。

这是我的代码:

Option Explicit  

Private flag As Boolean  

'Variables  
Dim x1 As Single, y1 As Single, x2 As Single, y2 As Single  

'Dibuja el circulo en el formulario  

Private Sub Dibujar_Circulo()        
    Dim cx As Single, cy As Single, dx As Single  
    Dim dy As Single, Radio As Single  

    cx = x1  
    cy = y1  
    dx = x1 - x2  
    dy = y1 - y2  

    ' calcula el radio  
    Radio = Sqr(dx * dx + dy * dy)  

    'Dibuja el círculo  
    Circle (cx, cy), Radio  
End Sub  

我只得到了一个没有任何动作的按钮:(

标签: excelvba

解决方案


推荐阅读