Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Help me with a function that checks if a variable in an .INI exists!


Braydo25
 Share

Recommended Posts

Lol, well this is making me pretty mad. Im trying to make a function that checks if there is a variable within an ini.

I tried something like:

public function CheckINIVar (EventName as string) as boolean

  dim a as integer

  on error goto Error

    for i = 0 to 10

    if getvar(app.path(blah blah blah),header,EventName) = i then    <– Eventname is the name of the var it looks for
      CheckINIVar = true
      end if

  Error

end function

but this always returns false, since getvar returns a string and a for loop must use integers in the var. so strings cant = integers (duh)

so, to fully explain it: This function needs to return TRUE if there is a variable named whatever EventName in CheckINIVar (EventName as string) is. and if there is not a variable named that then it returns a FALSE.

anyone got an idea?
Link to comment
Share on other sites

nvm, i was being dumb. I overlooked a really simple way to do it, instead i just did:

  Public Function CheckEvent(EventName as string) as boolean

  if getvar(blahblahblah,blah,EventName) = "" then
    CheckEvent = false

    else
    CheckEvent = true
      end if

end function.

lol, i forgot that when the variable isnt found it returns a vbnullstring.
Link to comment
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
 Share

×
×
  • Create New...