Jump to content

Convert Excel Formula to Autoit


thewind27
 Share

Recommended Posts

I have been worked on an Excel sheet which use ONLY cell A and B.

When I input the Hex MEID to cell A1, Cell B1 will show the result in Dec.

I use this formula in cell B for the conversion:

=HEX2DEC(LEFT(A1,8))&"0"&HEX2DEC(RIGHT(A1,6))

So my target is using the same method but put this on AutoIt

I created a GUI which has 2 large text box. The one on the left is to input the Hex values, the one on the right is output the Dec values. And 1 Convert button to execute this function

Please help me out, how can I translate the formula to AutoIt function.

Thanks

Link to comment
Share on other sites

This should be the equivalent:

Dec(StringLeft("your cell content here", 8))&"0"&Dec(StringRight("your cell content here", 6))
Just replace the text between quotes with the cell content and test it.

Edit: changed code tags to AutoIt tags.

Edited by enaiman

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

I didn't mean using AutoIt to work with Excel

I want 2 text boxes, the one on the left in INPUT and the one on the right is OUTPUT

For example: I put 5 lines of ENSs or MEIDs on the left. The right Text box will give me 5 lines of DEC ENSs in a perspectively

I dont want to use Excel any more

Link to comment
Share on other sites

I gave you a solution to what you wanted. From now on, it is in your hands.

Do a little bit of reading about GUICtrlRead, StringSplit, GUICtrlSetData ... what you want to do is easy, make the effort to do it yourself. It will help.

SNMP_UDF ... for SNMPv1 and v2c so far, GetBulk and a new example script

wannabe "Unbeatable" Tic-Tac-Toe

Paper-Scissor-Rock ... try to beat it anyway :)

Link to comment
Share on other sites

Thank you, guys!

I understand the concept of the function now. But i ran to another trouble. I dont know if my code is right but it doesn't work

Here it is:

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("MEID Converter", 243, 129, 192, 124)
$input = GUICtrlCreateInput("", 8, 8, 225, 21)
$output = GUICtrlCreateInput("", 8, 96, 225, 21)
$convert = GUICtrlCreateButton("Convert", 72, 40, 97, 41)
GUISetState(@SW_SHOW)

While 1
$nMsg = GUIGetMsg()
Switch $nMsg
  Case $GUI_EVENT_CLOSE
   Exit
  Case $convert
   $output= Dec(StringLeft($input, 8))&"0"&Dec(StringRight($input, 6))
EndSwitch
WEnd

Would you please check it for me? Thanks

Link to comment
Share on other sites

#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
$Form1 = GUICreate("MEID Converter", 243, 129, 192, 124)
$input = GUICtrlCreateInput("", 8, 8, 225, 21)
$output = GUICtrlCreateInput("", 8, 96, 225, 21)
$convert = GUICtrlCreateButton("Convert", 72, 40, 97, 41)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $convert
            GUICtrlSetData($output, Dec(StringLeft($input, 8))&"0"&Dec(StringRight($input, 6)))
    EndSwitch
WEnd

Is this any good?

Edited by czardas
Link to comment
Share on other sites

Well I don't understand what your code is meant to do exactly. Nor do I understand what you intend to type in the Input control. Perhaps you could provide some examples of the input and expected output. It looks like you want to convert a bunch of characters from the right and left hand side of a hex value to decimal, and then bang a zero between them. I'm not familiar with so many Excel formulas. What is the Hex MEID?

Edited by czardas
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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...