Sign in to follow this  
Followers 0
bigred

iniWrite an empty string

10 posts in this topic

I seem to have a problem with iniWrite in VB6 when I try and write an empty string to the key.

Is there any way to clear out a key?

I could have the code replace an empty string with something that I could handle later when I go to read the string, but thats not preferable.

Any ideas?

Share this post


Link to post
Share on other sites



Have you tried vbNull or vbStringNull? These might erase the value.

*** Matt @ MPCS

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

Ok, so you're saying set the string to one of those and then try and write it to the ini key?

I'll give it a try.

EDIT: Weird, it seems to have written "1 " (a one and a space) to the key when I use vbNull. Any ideas?

Also vbStringNull didn't work. VB6 thought it was a variable.

Edited by bigred

Share this post


Link to post
Share on other sites

vbStringNull is a variable, you could try sending that as your IniWrite parameter. I assume that in your code you set a string = vbNull, try changing its data type to a variant and see if that works. other than that without seeing your code there isn't a lot I can do to help. Hope something here was of assitsance!

*** Matt @ MPCS

Share this post


Link to post
Share on other sites

vbStringNull is a variable? I don't understand how that is helpful here?

No I don't set the string to equal vbNull, when I do that it writes a "1" to the key.

Here's the chunk of code I'm reffering too.

If ListSelMaps.ListIndex = -1 Then Exit Sub
    For iCounter = 0 To ListSelMaps.ListCount - 1
        ListSelMaps.Selected(iCounter) = False
        ListSelMaps.Selected(iCounter) = True
        If ListSelMaps.Selected(iCounter) = True Then
            Select Case iGameMode
                Case 1
                    sDA_Maps = sDA_Maps & ListSelMaps.Text & ","
                Case 2
                    sLC_Maps = sLC_Maps & ListSelMaps.Text & ","
                Case 3
                    sDM_Maps = sDM_Maps & ListSelMaps.Text & ","
            End Select
        End If
        ListSelMaps.Selected(iCounter) = False
    Next iCounter

    Select Case iGameMode
        Case 1
            If sDA_Maps = "" Then
                aix.IniWrite sTSMdata, "MAPS", "DiscArenaSelected", sDA_Maps
                Exit Sub
            Else
                aix.IniWrite sTSMdata, "MAPS", "DiscArenaSelected", sDA_Maps
            End If

Share this post


Link to post
Share on other sites

Well I am fresh out of ideas for using AutoIt to do it. You could always access the registry api directly. Search Planetsourcecode.com for ways to do this.

*** Matt @ MPCS

Share this post


Link to post
Share on other sites

The registry? I'm working with an ini file.

Share this post


Link to post
Share on other sites

Sorry that is what I meant... the functionality is almost identical for the API. It was late when I posted that so forgive a sleepy man.

*** Matt @ MPCS

Share this post


Link to post
Share on other sites

Heh, no worries.

I'll check out that site you mentioned. Thanks.

Share this post


Link to post
Share on other sites

I checked it out. Still no go.

Why does the autoitx iniwrite command crash the program?

Anyone have any ideas?

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  
Followers 0