Hey, I'm using Vb6 and I have a problem with my code but I don't know why.
Here it is:
The problem is when I run the program it says "Variable not defined" and highlights "n =" under "Private Sub Text1_Change()" but when I test this part of the code on it's own, it works fine, the other part of the code is for the opacity of the form and this works ok too.
When I put the code together I get the problem, Anyone know a solution?
Thanks, Darren.
Here it is:
Code:
Option Explicit 'Opacity ------------------------- Private Declare Function GetWindowLongA Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long) As Long Private Declare Function SetWindowLongA Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Private Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crey As Byte, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long Private Const GWL_EXSTYLE = (-20) Private Const WS_EX_LAYERED = &H80000 Private Const LWA_ALPHA = &H2& '-------------------------------------- Private Function Opacity(Value As Byte, Frm As Form) On Error GoTo ErrorHandler Dim MaxVal As Byte, MinVal As Byte MinVal = 20: MaxVal = 255 If Value > MaxVal Then Value = MaxVal If Value < MinVal Then Value = MinVal SetWindowLongA Frm.hwnd, GWL_EXSTYLE, GetWindowLongA(Frm.hwnd, GWL_EXSTYLE) Or WS_EX_LAYERED SetLayeredWindowAttributes Frm.hwnd, 0, Value, LWA_ALPHA ErrorHandler: Exit Function End Function Private Sub hsbOpacity_Change() Opacity hsbOpacity.Value, Me End Sub Private Sub Text1_Change() n = Text1 For i = 0 To n - 1 NewStr = NewStr + Text2.Text + ";" Next i Text3 = NewStr End Sub
When I put the code together I get the problem, Anyone know a solution?
Thanks, Darren.
Comment