Jump to content
Sign in to follow this  
diegophh

compile error : user-defined type not defined (vb6)

Recommended Posts

diegophh

e ai tudo bom pessoal?

estou tentando criar um aplicativo pra um jogo no visual basic , mais ta dando o seguinte erro "compile error : user defined type not defined error"    na seguinte linha ...

Sub FadeIn0(f As trainer)

valeu...

Share this post


Link to post
Share on other sites
programadorvb6

Olá.

Para teres um diagnóstico automático de erros no inicio de cada Form,Módulo ou classe etc..

Colocas :

'isto vai fazer com que te obrigue a declarar todo o tipo de variáveis evitando assim alguns erros + comuns
Option Explicit 
Sub FadeIn0(Dim f As trainer)

Share this post


Link to post
Share on other sites
programadorvb6

Olha o 'Option Explicit' é só no inicio.( não podes escrever + que 1 vezes que é a informação da menssagem), com toda a certeza que já existe no módulo caso se verifique não é preciso escrever +.

Além disso colocas-te o codigo em um módulo quando devia ser em um form.

O Melhor é pores á disposição todo o código.

Share this post


Link to post
Share on other sites
diegophh

aqui todo o codigo..

obrigado!

Option Explicit

Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Const FadeDelay = 5
Const FadeMax = 255
Declare Function SetWindowLong Lib "user32" _
   Alias "SetWindowLongA" (ByVal hwnd As Long, _
   ByVal nIndex As Long, ByVal dwNewLong As Long) _
   As Long

Global Const GWL_EXSTYLE = (-20)
Global Const WS_EX_LAYERED = &H80000
Global Const LWA_ALPHA = &H2

Declare Function GetWindowLong Lib "user32" _
  Alias "GetWindowLongA" (ByVal hwnd As Long, _
  ByVal nIndex As Long) As Long


Declare Function SetLayeredWindowAttributes Lib _
    "user32" (ByVal hwnd As Long, ByVal crKey As Long, _
    ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Global LastAlpha As Long

Sub FadeIn0(f As trainer)
Dim c
Dim ne As Integer, en(32767) As Boolean
For Each c In f.Controls
ne = ne + 1

Next
   TransTrainer f.hwnd, 200
    f.Show
    Dim i As Long
    For i = 200 To FadeMax Step 3
        TransTrainer2 f.hwnd, CByte(i)
        DoEvents
        Call Sleep(FadeDelay)
    Next
    TransTrainer2 f.hwnd, FadeMax
    i = 200
For Each c In f.Controls
i = i + 1
Next
End Sub

Sub FadeOut0(f As trainer)
On Local Error Resume Next
Dim c
For Each c In f.Controls
c.Enabled = False
Next
Dim i As Long
    For i = LastAlpha To 0 Step -3
        TransTrainer2 f.hwnd, CByte(i)
        DoEvents
        Call Sleep(FadeDelay)
    Next
End Sub

Public Function TransTrainer(fhWnd As Long, Alpha As Byte) As Boolean
    SetWindowLong fhWnd, GWL_EXSTYLE, WS_EX_LAYERED
    SetLayeredWindowAttributes fhWnd, 0, Alpha, LWA_ALPHA
    LastAlpha = Alpha
End Function


Share this post


Link to post
Share on other sites
jluisfer

Eu acho que o mal está quando dizes f as trainer,parece-me a mim que ele não deve saber o que e isso do trainer.Ligaste alguma referência onde esse trainer está definido?

Share this post


Link to post
Share on other sites
programadorvb6

Boas .

Não sei se é isto que queres.

No : Form1 cola este codigo e adiciona um botão.

Private Sub Command1_Click()
FadeIn0 Form1

End Sub

Cria um módulo cola este código:

Option Explicit

Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Const FadeDelay = 5
Const FadeMax = 255
Declare Function SetWindowLong Lib "user32" _
   Alias "SetWindowLongA" (ByVal hwnd As Long, _
   ByVal nIndex As Long, ByVal dwNewLong As Long) _
   As Long

Global Const GWL_EXSTYLE = (-20)
Global Const WS_EX_LAYERED = &H80000
Global Const LWA_ALPHA = &H2

Declare Function GetWindowLong Lib "user32" _
  Alias "GetWindowLongA" (ByVal hwnd As Long, _
  ByVal nIndex As Long) As Long


Declare Function SetLayeredWindowAttributes Lib _
    "user32" (ByVal hwnd As Long, ByVal crKey As Long, _
    ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long
Global LastAlpha As Long

Sub FadeIn0(f As Form)
Dim c
Dim ne As Integer, en(32767) As Boolean
For Each c In f.Controls
ne = ne + 1

Next
   TransTrainer f.hwnd, 20
    f.Show
    Dim i As Long
    For i = 20 To FadeMax Step 3
        TransTrainer2 f.hwnd, CByte(i)
        DoEvents
        Call Sleep(FadeDelay)
    Next
    TransTrainer2 f.hwnd, FadeMax
    i = 20
For Each c In f.Controls
i = i + 1
Next
End Sub

Sub FadeOut0(f As Form)
On Local Error Resume Next
Dim c
For Each c In f.Controls
c.Enabled = False
Next
Dim i As Long
    For i = LastAlpha To 0 Step -3
        TransTrainer2 f.hwnd, CByte(i)
        DoEvents
        Call Sleep(FadeDelay)
    Next
End Sub

Public Function TransTrainer(fhWnd As Long, Alpha As Byte) As Boolean
    SetWindowLong fhWnd, GWL_EXSTYLE, WS_EX_LAYERED
    SetLayeredWindowAttributes fhWnd, 0, Alpha, LWA_ALPHA
    LastAlpha = Alpha
End Function

Public Function TransTrainer2(fhWnd As Long, Alpha As Byte) As Boolean
    SetWindowLong fhWnd, GWL_EXSTYLE, WS_EX_LAYERED
    SetLayeredWindowAttributes fhWnd, 0, Alpha, LWA_ALPHA
    LastAlpha = Alpha
End Function

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×
×
  • Create New...

Important Information

By using this site you accept our Terms of Use and Privacy Policy. We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.