|
-
Nov 27th, 2000, 12:59 PM
#1
Thread Starter
Frenzied Member
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
-
Nov 27th, 2000, 01:08 PM
#2
Fanatic Member
You can test it out, by deleting that key in your registry.
-
Nov 27th, 2000, 01:14 PM
#3
Thread Starter
Frenzied Member
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?
-
Nov 27th, 2000, 01:18 PM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|