2015-04-17 89 views
-1

嗨即時嘗試創建一個簡單的程序涉及對象和類內 VB 6.0。「用戶定義的類型未定義」錯誤

該錯誤消息我得到的是:「沒有定義用戶定義的類型」

的強調,VB懷疑爲「昏暗鮑勃由於球」

我的定義的類是如下代碼:

Dim Bob As Object 

Public Sub Ball() 

Dim Circlex As Integer 
Dim Circley As Integer 

Public Sub makeBall() 
Circlex = 3000 
Circley = 3000 
End Sub 

Private Sub moveBall() 
Circle (Circlex, Circley), 200 
End Sub 

End Sub 

我爲我的項目中唯一的形式代碼:

Private Sub Command1_Click() 
Command1.Visible = False 
Command1.Enabled = False 
vbalProgressBar1.Visible = True 
Timer1.Enabled = True 
Beep 
End Sub 

Private Sub Form_Load() 
Form1.Width = 6000 
Form1.Height = 6000 
Dim Bob As Ball 
Dim Bob As New Ball 
End Sub 

Private Sub Form_Unload(Cancel As Integer) 
If MsgBox("Are you sure you want to be a quitter?!" 
, vbYesNo,"Quit?") = vbYes Then 
Unload Me 
Set Form1 = Nothing 
Else 
Cancel = 1 
End If 
End Sub 

Private Sub Timer1_Timer() 
Bob = moveBall(Circlex, Circley) 
End Sub 

林不知道w ^可疑的代碼行不正確,但任何幫助將不勝感激!

+2

,除非你有一個名爲'Ball'的類或結構,錯誤信息是正確的 – Plutonix

+0

[用戶定義類型未定義--Excel宏]可能的重複(http://stackoverflow.com/questions/24261557/user-defined-type-不定義-Excel的宏) –

回答

0

VB6不使用您編碼的代碼風格。 你必須遵循這些方法才能使代碼符合你的意圖。 1.化妝classmodule 2.設置其名稱 '球' 3.糊上classmodule此代碼

Dim Circlex As Integer 
Dim Circley As Integer 

Public Sub makeBall() 
Circlex = 3000 
Circley = 3000 
End Sub 

Private Sub moveBall() 
Circle (Circlex, Circley), 200 
End Sub 
表單上
  • 粘貼代碼

    Private Sub Command1_Click() 
    Command1.Visible = False 
    Command1.Enabled = False 
    vbalProgressBar1.Visible = True 
    Timer1.Enabled = True 
    Beep 
    
    End Sub 
    
    Private Sub Form_Load() 
    Form1.Width = 6000 
    Form1.Height = 6000 
    Dim Bob As New Ball 
    End Sub 
    
    Private Sub Form_Unload(Cancel As Integer) 
    If MsgBox("Are you sure you want to be a quitter?!" 
    , vbYesNo,"Quit?") = vbYes Then 
    Unload Me 
    Set Form1 = Nothing 
    Else 
    Cancel = 1 
    End If 
    End Sub 
    
    Private Sub Timer1_Timer() 
    Bob.moveBall(Circlex, Circley) 
    End Sub 
    
  • 此外,VB6不支持風格像

    Sub A() 
        Sub B() 
        End Sub 
    End Sub 
    
    相關問題