Totally Lost and needing help...


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Totally Lost and needing help...

Hybrid View

  1. #1
    Anthony M. Saffer Guest

    Totally Lost and needing help...


    Hello!
    I have created a control that will perform a very simple function: connect
    and disconnect from the Internet with a single call. It uses API calls to
    accomplish this thereby insulating the developer from the API. But I am
    totally lost now because when I try to create my .OCX file I get an error
    message telling me that Nothing but comments can appear after an END SUB,
    END FUNCTION or END PROPERTY. I really hate to post this much code but could
    someone look over this and tell me what is wrong? This is a rather important
    project so I really appreciate your help.

    Thanks,
    Anthony (Code Below):

    ========================== BEGIN CODE ==========================

    'Default Property Values:
    Const m_def_BackColor = 0
    Const m_def_ForeColor = 0
    Const m_def_Enabled = 0
    Const m_def_BackStyle = 0
    Const m_def_BorderStyle = 0
    'Property Variables:
    Dim m_BackColor As Long
    Dim m_ForeColor As Long
    Dim m_Enabled As Boolean
    Dim m_Font As Font
    Dim m_BackStyle As Integer
    Dim m_BorderStyle As Integer
    'Event Declarations:
    Event Click()
    Event DblClick()
    Event KeyDown(KeyCode As Integer, Shift As Integer)
    Event KeyPress(KeyAscii As Integer)
    Event KeyUp(KeyCode As Integer, Shift As Integer)
    Event MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Event MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Event MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)



    Public Property Get BackColor() As Long
    BackColor = m_BackColor
    End Property

    Public Property Let BackColor(ByVal New_BackColor As Long)
    m_BackColor = New_BackColor
    PropertyChanged "BackColor"
    End Property

    Public Property Get ForeColor() As Long
    ForeColor = m_ForeColor
    End Property

    Public Property Let ForeColor(ByVal New_ForeColor As Long)
    m_ForeColor = New_ForeColor
    PropertyChanged "ForeColor"
    End Property

    Public Property Get Enabled() As Boolean
    Enabled = m_Enabled
    End Property

    Public Property Let Enabled(ByVal New_Enabled As Boolean)
    m_Enabled = New_Enabled
    PropertyChanged "Enabled"
    End Property

    Public Property Get Font() As Font
    Set Font = m_Font
    End Property

    Public Property Set Font(ByVal New_Font As Font)
    Set m_Font = New_Font
    PropertyChanged "Font"
    End Property

    Public Property Get BackStyle() As Integer
    BackStyle = m_BackStyle
    End Property

    Public Property Let BackStyle(ByVal New_BackStyle As Integer)
    m_BackStyle = New_BackStyle
    PropertyChanged "BackStyle"
    End Property

    Public Property Get BorderStyle() As Integer
    BorderStyle = m_BorderStyle
    End Property

    Public Property Let BorderStyle(ByVal New_BorderStyle As Integer)
    m_BorderStyle = New_BorderStyle
    PropertyChanged "BorderStyle"
    End Property

    Public Sub Refresh()

    End Sub

    Public Function InetConnect() As Variant
    'This function will create a connection to the default ISP on the
    'users machine.


    hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_DIRECT, vbNullString,
    vbNullString, 0)


    End Function

    Public Function InetHangup() As Variant
    'This function will disconnect from the default connection on the
    'users ISP.

    InternetCloseHandle hOpen
    End Function

    'Initialize Properties for User Control
    Private Sub UserControl_InitProperties()

    Const scUserAgent = "Internet Connection"
    Const INTERNET_OPEN_TYPE_DIRECT = 1
    Const INTERNET_OPEN_TYPE_PROXY = 3
    Const INTERNET_FLAG_RELOAD = &H80000000
    Public Declare Function InternetOpen Lib "wininet" Alias "InternetOpenA"
    (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String,
    ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
    Public Declare Function InternetCloseHandle Lib "wininet" (ByVal hInet As
    Long) As Integer
    Public Declare Function InternetReadFile Lib "wininet" (ByVal hFile As Long,
    ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead
    As Long) As Integer
    Public Declare Function InternetOpenUrl Lib "wininet" Alias "InternetOpenUrlA"
    (ByVal hInternetSession As Long, ByVal lpszUrl As String, ByVal lpszHeaders
    As String, ByVal dwHeadersLength As Long, ByVal dwFlags As Long, ByVal dwContext
    As Long) As Long

    m_BackColor = m_def_BackColor
    m_ForeColor = m_def_ForeColor
    m_Enabled = m_def_Enabled
    Set m_Font = Ambient.Font
    m_BackStyle = m_def_BackStyle
    m_BorderStyle = m_def_BorderStyle
    End Sub

    'Load property values from storage
    Private Sub UserControl_ReadProperties(PropBag As PropertyBag)

    m_BackColor = PropBag.ReadProperty("BackColor", m_def_BackColor)
    m_ForeColor = PropBag.ReadProperty("ForeColor", m_def_ForeColor)
    m_Enabled = PropBag.ReadProperty("Enabled", m_def_Enabled)
    Set m_Font = PropBag.ReadProperty("Font", Ambient.Font)
    m_BackStyle = PropBag.ReadProperty("BackStyle", m_def_BackStyle)
    m_BorderStyle = PropBag.ReadProperty("BorderStyle", m_def_BorderStyle)
    End Sub

    'Write property values to storage
    Private Sub UserControl_WriteProperties(PropBag As PropertyBag)

    Call PropBag.WriteProperty("BackColor", m_BackColor, m_def_BackColor)
    Call PropBag.WriteProperty("ForeColor", m_ForeColor, m_def_ForeColor)
    Call PropBag.WriteProperty("Enabled", m_Enabled, m_def_Enabled)
    Call PropBag.WriteProperty("Font", m_Font, Ambient.Font)
    Call PropBag.WriteProperty("BackStyle", m_BackStyle, m_def_BackStyle)
    Call PropBag.WriteProperty("BorderStyle", m_BorderStyle, m_def_BorderStyle)
    End Sub



  2. #2
    David Crowell Guest

    Re: Totally Lost and needing help...

    Try moving the Declare statements, and Constants up before any subs or
    functions (or property procedures)

    Dave
    www.davidcrowell.com


    "Anthony M. Saffer" <apsaffer@hotmail.com> wrote in message
    news:39b530d1$1@news.devx.com...
    >
    > Hello!
    > I have created a control that will perform a very simple function:

    connect
    > and disconnect from the Internet with a single call. It uses API calls to
    > accomplish this thereby insulating the developer from the API. But I am
    > totally lost now because when I try to create my .OCX file I get an error
    > message telling me that Nothing but comments can appear after an END SUB,
    > END FUNCTION or END PROPERTY. I really hate to post this much code but

    could
    > someone look over this and tell me what is wrong? This is a rather

    important
    > project so I really appreciate your help.


    <code snipped>



  3. #3
    Anthony M. Saffer Guest

    Re: Totally Lost and needing help...


    Dave,
    Just tried it and it didn't seem to work. I took all of my constants and
    declare statement and moved them to the top of my code - before ANYTHING
    else. It told me that I couldn't have declare statements, constants, arrays,
    etc, in public areas of the code. Any ideas?

    Anthony


  4. #4
    David Crowell Guest

    Re: Totally Lost and needing help...

    try Private Declare ....
    and Private Const.....

    you get the idea...

    Dave
    www.davidcrowell.com

    "Anthony M. Saffer" <apsaffer@hotmail.com> wrote in message
    news:39b542cb$1@news.devx.com...
    >
    > Dave,
    > Just tried it and it didn't seem to work. I took all of my constants and
    > declare statement and moved them to the top of my code - before ANYTHING
    > else. It told me that I couldn't have declare statements, constants,

    arrays,
    > etc, in public areas of the code. Any ideas?
    >
    > Anthony
    >




  5. #5
    Anthony Saffer Guest

    Re: Totally Lost and needing help...


    Dave,
    Yep, I do get the idea and it worked like a charm! Thanks for the help!

    Anthony


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center