Use this:

 

Dim Hexa

Hexa = 409

Dim Dec

    Dec = CInt("&h" & Hexa)

msgbox Dec

 

 

From: David [mailto:[email protected]] 
Sent: Thursday, May 31, 2012 11:43 AM
To: [email protected]
Subject: Re: Registering new keys in the INI file

 

Jeff,

Thanks.

 

Your suggested way, will work, in all cases where I can hard-code the number
- the way I read it.

 

But, what if I have something like this:

    Dim Hexa

    Hexa = 409

If I now do:

    Dim Dec

    Dec = CInt(Hexa)

I simply get 409, as the return value. I see you add the &H to the number in
your example, but how do I add that to a Variable? Do I make sense?

 

In my exampel above, the Hexa variable could even be calculated at the fly,
so can't hard-code it.

 

Thanks again,

    

----- Original Message ----- 

From: Jeff Bishop <mailto:[email protected]>  

To: [email protected] 

Sent: Thursday, May 31, 2012 8:05 PM

Subject: RE: Registering new keys in the INI file

 

Sure, use:

 

CInt("&h0a")

 

Where 0a is the hex value of your choice.

 

From: David [mailto:[email protected]] 
Sent: Thursday, May 31, 2012 10:59 AM
To: [email protected]
Subject: Re: Registering new keys in the INI file

 

Thanks,

Sure you are right, the read command should be

    Incoming = Input.ReadLine

 

Further, I got it working, after changing the MIF.Text line to read

    MIF.Text( "MyKeys", CStr(NewKey)) = Value

 

So, had to convert the NewKey variable, to a String first. :)

 

One more question:

Is there a quick way to convert a hex value, into an integer or long value?
I.e, you can do:

    x = hex(1033)

and you would get something like 409. But, what if you want to convert the
hex number 409, into an integer? Sorry, but my mind is blank, as to how to
do that. 

 

Thanks again.

 

----- Original Message ----- 

From: Doug Geoffray <mailto:[email protected]>  

To: [email protected] 

Sent: Thursday, May 31, 2012 7:25 PM

Subject: Re: Registering new keys in the INI file

 

David,

Your Window-Eyes part of this is fine.

But when you are reading the line, shouldn't your line be something like:

Incoming = InputFile.ReadLine

Its been awhile since I've done the text file reading stuff so I can't
remember for sure.

But bottom line, my guess would be the Incoming variable isn't what you
think it is.  if you hard code the Incoming variable to a string, you'll see
it works fine.

Doug

On 5/31/2012 12:46 PM, David wrote: 

OK, I am playing around with some INI stuff. Somehow it does not work. Am I
doing something wrong, or does it not work due to the feature not being
supported?

 

I have the need for saving some keys and values on the fly. Fact is, that
even the keys might be created on the fly, due to some actions performed in
the app. A basic example, would be like this:

 

 InputFile.ReadLine Incoming
 Value = 93
 RegIni( Incoming )
Sub RegIni( NewKey )
 Set MIF = IniFile( ClientInformation.ScriptPath &"\MyApp.ini" )
 MIF.Text( "MyKeys", NewKey ) = Value
Set MIF = Nothing
End Sub 'RegIni.

 

OK, so in this example, we read a string from a source, like a file. This
string, would be the name of our new key. We then set the Value to a number,
it could be either a hard-coded value, or something created by the app on
the fly.

 

Next, The sub RegIni is being called. Reason for putting it into a sub, is
that then we can call it at any time in the code processing, without
repeating the lines in our code. Besides, makes the stuff a bit more tidy.

 

My Idea was to have the sub create the new key, with the incoming name,
under the section named 
MyKeys. This section already exists in the INI file. Well, the thing is,
that running the above code, does NOT add a new key to the INI. It actually
does do nothing to the INI file at all. Have a feeling I am missing
something here. But what?

 

Any feedback is more than welcome here.

Reply via email to