Results 1 to 4 of 4

Thread: App crashes - Runtime error 383

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276
    I have an app that I have developed which works fine on my
    computer. I tried to run it on another computer and the
    first thing I get is The 383 runtime error because apparently
    I am trying to set a read-only property. I click OK and that is all I get.
    It would seem to be code in the form load event.
    Look at the code below and see if you can find any problems.

    Code:
    Private Sub Form_Load()
    
        If App.PrevInstance Then
            AppActivate App.Title
            Unload Me
        End If
     
        Label2.Caption = Now
        'I DON'T THINK IT COULD BE HERE
    
        Winsock1.RemoteHost = "tick.usno.navy.mil"
        Winsock1.RemotePort = 13
        Winsock1.Connect
        
        Combo.Text = GetSetting("clock", "Settings", "Combo", 0)
        'MAYBE HERE   
    
    End Sub
    It doesn't make sense why I can't set these simple properties on startup.
    My only idea is that on form unload I set the property
    of Combo.Text and since the program hasn't run yet, the
    GetSetting has nothing to return.

    If so, will this fix the problem?
    Code:
    If GetSetting("clock", "Settings", "Combo", 0) = "" Then
            Exit Sub
        Else
            Combo.Text = GetSetting("clock", "Settings", "Combo", 0)
        End If

  2. #2
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    You can test it out, by deleting that key in your registry.
    Oetje
    [email protected]
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276
    Per VB Help:
    "If any of the items named in the GetSetting arguments do not exist, GetSetting returns the value of default."

    So doesn't this mean that on startup, my ComboBox should just be blank since GetSetting returns "".

    Do I need to use DeleteSetting to free the registry entries?

  4. #4
    old fart Frans C's Avatar
    Join Date
    Oct 1999
    Location
    the Netherlands
    Posts
    2,926
    I guess you have set the Style property of the combobox to 2 - Dropdown List.
    With this setting, you can only set the text property to an entry in the list. Setting the text property to another value will return this error.

    Your solution will not work, since you used zero as the default value for getsetting, so it will not return "".

    This should do the trick:
    Code:
        If GetSetting("clock", "Settings", "Combo", "") <> "" Then
            Combo.Text = GetSetting("clock", "Settings", "Combo", "")
        End If
    It would be nicer to store the value in a variable, so you don't have to read the registry 2 times.
    Code:
    Dim sText As String
        sText = GetSetting("clock", "Settings", "Combo", "")
        If sText <> "" Then
            Combo.Text = sText
        End If

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width