help with making simple excel type database with autoit

I'm having an issue with the program i'm trying to make. what i would like to do is take and read the data from column A in a excel sheet and populate a dropdown so the user can select the item (can't be duplicate) Then add asset tags and so forth.  here is my code I have so far but i'm very much so lost.

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <Excel.au3>
#include <Array.au3>
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=
$Form1 = GUICreate("Stock Room Inventory System", 598, 421, 192, 124)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Form1Restore")
$Tab1 = GUICtrlCreateTab(0, 0, 617, 433)
GUICtrlSetOnEvent(-1, "Tab1Change")
$TabSheet1 = GUICtrlCreateTabItem("Add Inventory")
$Label1 = GUICtrlCreateLabel("Item Name", 8, 40, 55, 17)
GUICtrlSetOnEvent(-1, "Label1Click")
$Combo1 = GUICtrlCreateCombo("Type or Select Item", 8, 56, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
Global $sFilePath1 = "u:\database.xls" ;This file should already exist
Global $oExcel =  _ExcelBookOpen($sFilePath1,0)
Global $aArray = _ExcelReadSheetToArray($oExcel) ;Using Default Parameters
GUICtrlSetOnEvent(-1, "Combo1Change")
$Input1 = GUICtrlCreateInput("Scan or Enter Asset Number", 336, 64, 153, 21)
GUICtrlSetOnEvent(-1, "Input1Change")
$Label2 = GUICtrlCreateLabel("Asset Number", 336, 48, 70, 17)
GUICtrlSetOnEvent(-1, "Label2Click")
$Button1 = GUICtrlCreateButton("Submit Data", 224, 136, 75, 25)
GUICtrlSetOnEvent(-1, "Button1Click")
GUICtrlSetState($tabsheet1,$GUI_SHOW)
GUISetState(@SW_SHOW)
$TabSheet2 = GUICtrlCreateTabItem("Use Inventory")
$Label3 = GUICtrlCreateLabel("Please enter Asset Tag to remove", 16, 48, 161, 17)
GUICtrlSetOnEvent(-1, "Label3Click")
$Input2 = GUICtrlCreateInput("", 16, 64, 161, 21)
GUICtrlSetOnEvent(-1, "Input2Change")
$Process = GUICtrlCreateButton("Process", 200, 128, 75, 25)
GUICtrlSetOnEvent(-1, "ProcessClick")
$Status_lbl = GUICtrlCreateLabel("", 104, 232, 4, 4)
GUICtrlSetOnEvent(-1, "Status_lblClick")
$TabSheet3 = GUICtrlCreateTabItem("Reports")
$Label4 = GUICtrlCreateLabel("Select inventory item", 16, 56, 102, 17)
GUICtrlSetOnEvent(-1, "Label4Click")
$List1 = GUICtrlCreateList("", 16, 72, 321, 97)
GUICtrlSetOnEvent(-1, "List1Click")
$Label5 = GUICtrlCreateLabel("Number of Items in Stock", 288, 216, 123, 17)
GUICtrlSetOnEvent(-1, "Label5Click")
$Input3 = GUICtrlCreateInput("", 424, 212, 121, 21)
GUICtrlSetOnEvent(-1, "Input3Change")
  
  for $i = 1 to UBound($aArray) -1
	 $cdata = $aArray[$i][1]
	 GUICtrlSetData($combo1,$cdata)
  Next

#EndRegion ### END Koda GUI section ###




While 1
	Sleep(100)
	
	  
	

WEnd



   
   
Func Button1Click()

EndFunc
Func Combo1Change()
   
  
EndFunc
Func Form1Close()

EndFunc
Func Form1Maximize()

EndFunc
Func Form1Minimize()

EndFunc
Func Form1Restore()

EndFunc
Func Input1Change()

EndFunc
Func Input2Change()

EndFunc
Func Input3Change()

EndFunc
Func Label1Click()

EndFunc
Func Label2Click()

EndFunc
Func Label3Click()

EndFunc
Func Label4Click()

EndFunc
Func Label5Click()

EndFunc
Func List1Click()

EndFunc
Func ProcessClick()

EndFunc
Func Status_lblClick()

EndFunc
Func Tab1Change()

EndFunc

Open in new window

bbimisAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

matrixnzCommented:
Can you explain what the issue is?
0
bbimisAuthor Commented:
here is an updated script that works per say.
The issue i'm having is in the list the item selected is generally never the first item. I would like the default item to at position 1. Can't figure out how to do that.
Here is the code:
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <excel.au3>
#include <array.au3>
Opt("GUIOnEventMode", 1)
#Region ### START Koda GUI section ### Form=U:\inventory system.kxf
$Form1_1 = GUICreate("Inventory System By Tony Stegall V 1.0", 570, 395, 186, 120)
GUISetOnEvent($GUI_EVENT_CLOSE, "Form1Close")
GUISetOnEvent($GUI_EVENT_MINIMIZE, "Form1Minimize")
GUISetOnEvent($GUI_EVENT_MAXIMIZE, "Form1Maximize")
GUISetOnEvent($GUI_EVENT_RESTORE, "Form1_Restore")
$Tab1 = GUICtrlCreateTab(0, 0, 609, 441)
GUICtrlSetOnEvent(-1, "Tab1Change")
$Add_Tab = GUICtrlCreateTabItem("Add Item(s)")
$Label3 = GUICtrlCreateLabel("Enter Item name if not listed above", 32, 256, 167, 17)
GUICtrlSetOnEvent(-1, "Label3Click")
$Label1 = GUICtrlCreateLabel("Select item from list or add new item below", 32, 64, 203, 17)
GUICtrlSetOnEvent(-1, "Label1Click")
$List1 = GUICtrlCreateList("", 32, 80, 201, 162)
GUICtrlSetOnEvent(-1, "List1Click")
$newitemname_input = GUICtrlCreateInput("", 36, 273, 185, 21)
GUICtrlSetOnEvent(-1, "Input1Change")
$Submit = GUICtrlCreateButton("Submit", 400, 336, 75, 25)
GUICtrlSetOnEvent(-1, "SubmitClick")
$Label2 = GUICtrlCreateLabel("Enter Asset Tag", 336, 72, 80, 17)
GUICtrlSetOnEvent(-1, "Label2Click")
$newasset_input = GUICtrlCreateInput("", 424, 68, 121, 21)
GUICtrlSetOnEvent(-1, "Input2Change")
$status_lbl = GUICtrlCreateLabel("", 128, 336, 250, 21)
GUICtrlSetOnEvent(-1, "status_lblClick")
$Remove_Tab = GUICtrlCreateTabItem("Remove From Stock")
$Input3 = GUICtrlCreateInput("Input3", 240, 168, 1, 21)
GUICtrlSetOnEvent(-1, "Input3Change")
$Label5 = GUICtrlCreateLabel("Enter Asset Tag to remove item from Stock Inventory", 162, 112, 253, 17)
GUICtrlSetOnEvent(-1, "Label5Click")
$Input4 = GUICtrlCreateInput("", 162, 152, 253, 21)
GUICtrlSetOnEvent(-1, "Input4Change")
$Button1 = GUICtrlCreateButton("Remove", 248, 216, 75, 25)
GUICtrlSetOnEvent(-1, "Button1Click")
$TabSheet1 = GUICtrlCreateTabItem("Current Stock")
$List2 = GUICtrlCreateList("", 8, 24, 177, 344)
GUICtrlSetOnEvent(-1, "List2Click")
$Label4 = GUICtrlCreateLabel("Amount in Stock:", 272, 104, 85, 17)
GUICtrlSetOnEvent(-1, "Label4Click")
$Input5 = GUICtrlCreateInput("", 360, 104, 85, 21)
GUICtrlSetOnEvent(-1, "Input5Change")
GUICtrlCreateTabItem("")
GUISetState(@SW_SHOW)
#EndRegion ### END Koda GUI section ###
Global $s_Filename=FileGetShortName("database.xls") 
Global $s_Tablename = "[Sheet1$]" 
; populate the inventory  item list
 ;valueinput()
itemslist()

$tabed = 0
While 1
	Sleep(100)
	$msg = GUIGetMsg()
    Select
        Case $msg = $GUI_EVENT_CLOSE
            ExitLoop
        Case GUICtrlRead($tab1) = 0 And $tabed <> 0
            $tabed = 0
            itemslist()
		 Case GUICtrlRead($tab1) = 1 And $tabed <> 1
            $tabed = 1
            remove()
        Case GUICtrlRead($tab1) = 2 And $tabed <> 2
            $tabed = 2
            reportlist()
    EndSelect

	
	
	
	WEnd

Func Button1Click()

EndFunc
Func Form1Close()
exit
EndFunc
Func Form1Maximize()

EndFunc
Func Form1Minimize()

EndFunc
Func Form1Restore()

EndFunc
Func Input1Change()

EndFunc
Func Input2Change()

EndFunc
Func Input3Change()

EndFunc
Func Input4Change()

EndFunc
Func Label1Click()

EndFunc
Func Label2Click()

EndFunc
Func Label3Click()

EndFunc
Func Label5Click()

EndFunc
Func List1Click()

EndFunc
Func List2Click()
$listclickdata = GUICtrlRead($list2)
ValueInput($listclickdata)
EndFunc
Func SubmitClick()
   if guictrlread($newasset_input) ="" Then
		 msgbox (0,"Error","You must enter an asset tag")
	  Else
		 $assettag = GUICtrlRead($newasset_input)
		 if GUICtrlRead($newitemname_input) ="" then
			insertitem(guictrlread($list1),GUICtrlRead($newasset_input))
		 Else
			insertitem(GUICtrlRead($newitemname_input),GUICtrlRead($newasset_input))
		 EndIf
   endif
   guictrlsetdata($status_lbl,"Asset tag: "& $assettag & " has been added")
   GUICtrlSetData($newasset_input,"")
   
itemslist(); refesh the items list
EndFunc
Func Tab1Change()

EndFunc
func remove()
   MsgBox(0,"working on this","working on this")
EndFunc

func reportlist ()
Const $adOpenStatic = 3
Const $adLockOptimistic = 3
Const $adCmdText = 0x0001 


; Initialize COM error handler 
global $oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

; Source XLS data
$objConnection = ObjCreate("ADODB.Connection")
$objRecordSet = ObjCreate("ADODB.Recordset")
$objConnection.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&$s_Filename&";Extended Properties=""Excel 8.0;HDR=Yes;"";")
$objRecordSet.Open ("Select items FROM "& $s_Tablename, $objConnection, $adOpenStatic, $adLockOptimistic, $adCmdText)

Do
   
    ;guictrlsetdata($input5, $objrecordset.fields("items").value  & "= " & $objrecordset.fields("rcount").value)
	; guictrlsetdata($input5, $objrecordset.fields("rcount").value)
	guictrlsetdata($list2, $objrecordset.fields("items").value)
	   
    $objRecordSet.MoveNext
 Until $objRecordSet.EOF
; $objRecordSet = ""
 ;$objRecordSet.Open ("Select * FROM "& $s_Tablename, $objConnection, $adOpenStatic, $adLockOptimistic, $adCmdText)

$objConnection.Close
$objConnection = ""
$objRecordSet = ""
EndFunc





Func ValueInput($valueLookup)
   
Const $adOpenStatic = 3
Const $adLockOptimistic = 3
Const $adCmdText = 0x0001 
; Initialize COM error handler 
global $oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

; Source XLS data
$objConnection = ObjCreate("ADODB.Connection")
$objRecordSet = ObjCreate("ADODB.Recordset")
$objConnection.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&$s_Filename&";Extended Properties=""Excel 8.0;HDR=Yes;"";")
;$objRecordSet.Open ("SELECT COUNT(*) AS rcount FROM "& $s_Tablename & " WHERE items='keyboard'" & $valueLookup, $objConnection, $adOpenStatic, $adLockOptimistic, $adCmdText)
$query ="SELECT COUNT(*) AS rcount FROM "& $s_Tablename & " WHERE items='"& $valueLookup &"'"
$objRecordSet.Open ($query, $objConnection, $adOpenStatic, $adLockOptimistic, $adCmdText)
Do
   
    ;guictrlsetdata($input5, $objrecordset.fields("items").value  & "= " & $objrecordset.fields("rcount").value)
	guictrlsetdata($input5, $objrecordset.fields("rcount").value)
	;guictrlsetdata($list2, $objrecordset.fields("items").value)
	   
    $objRecordSet.MoveNext
 Until $objRecordSet.EOF
; $objRecordSet = ""
 ;$objRecordSet.Open ("Select * FROM "& $s_Tablename, $objConnection, $adOpenStatic, $adLockOptimistic, $adCmdText)

$objConnection.Close
$objConnection = ""
$objRecordSet = ""
   
EndFunc


Func MyErrFunc()
  $HexNumber=hex($oMyError.number,8)
  Msgbox(0,"COM Test","We intercepted a COM Error !"       & @CRLF  & @CRLF & _
             "err.description is: "    & @TAB & $oMyError.description    & @CRLF & _
             "err.windescription:"     & @TAB & $oMyError.windescription & @CRLF & _
             "err.number is: "         & @TAB & $HexNumber              & @CRLF & _
             "err.lastdllerror is: "   & @TAB & $oMyError.lastdllerror   & @CRLF & _
             "err.scriptline is: "     & @TAB & $oMyError.scriptline     & @CRLF & _
             "err.source is: "         & @TAB & $oMyError.source         & @CRLF & _
             "err.helpfile is: "       & @TAB & $oMyError.helpfile       & @CRLF & _
             "err.helpcontext is: "    & @TAB & $oMyError.helpcontext _
            )
  SetError(1)  ; to check for after this function returns
Endfunc


Func ItemsList()
   
Const $adOpenStatic = 3
Const $adLockOptimistic = 3
Const $adCmdText = 0x0001 
; Initialize COM error handler 
global $oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

; Source XLS data
$objConnection = ObjCreate("ADODB.Connection")
$objRecordSet = ObjCreate("ADODB.Recordset")
$objConnection.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&$s_Filename&";Extended Properties=""Excel 8.0;HDR=Yes;"";")
;$objRecordSet.Open ("SELECT COUNT(*) AS rcount FROM "& $s_Tablename & " WHERE items='keyboard'" & $valueLookup, $objConnection, $adOpenStatic, $adLockOptimistic, $adCmdText)
$query ="SELECT items FROM "& $s_Tablename
$objRecordSet.Open ($query, $objConnection, $adOpenStatic, $adLockOptimistic, $adCmdText)
Do
   
    ;guictrlsetdata($input5, $objrecordset.fields("items").value  & "= " & $objrecordset.fields("rcount").value)
	guictrlsetdata($list1, $objrecordset.fields("items").value)
	
	;guictrlsetdata($list2, $objrecordset.fields("items").value)
	   
    $objRecordSet.MoveNext
 Until $objRecordSet.EOF
; $objRecordSet = ""
 ;$objRecordSet.Open ("Select * FROM "& $s_Tablename, $objConnection, $adOpenStatic, $adLockOptimistic, $adCmdText)

$objConnection.Close
$objConnection = ""
$objRecordSet = ""
EndFunc
   
   
   
   
Func InsertItem($s_itemvalue,$s_assetvalue)
      
Const $adOpenStatic = 3
Const $adLockOptimistic = 3
Const $adCmdText = 0x0001 
; Initialize COM error handler 
global $oMyError = ObjEvent("AutoIt.Error","MyErrFunc")

; Source XLS data
$objConnection = ObjCreate("ADODB.Connection")
$objRecordSet = ObjCreate("ADODB.Recordset")
$objConnection.Open ("Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&$s_Filename&";Extended Properties=""Excel 8.0;HDR=Yes;"";")
;$objRecordSet.Open ("SELECT COUNT(*) AS rcount FROM "& $s_Tablename & " WHERE items='keyboard'" & $valueLookup, $objConnection, $adOpenStatic, $adLockOptimistic, $adCmdText)
$query ="INSERT INTO "& $s_Tablename & " (items, assets) values ('" & $s_itemvalue&"', '"& $s_assetvalue &"')"
$objRecordSet.Open ($query, $objConnection, $adOpenStatic, $adLockOptimistic, $adCmdText)
$objConnection.Close
$objConnection = ""
$objRecordSet = ""
EndFunc

Open in new window

0
matrixnzCommented:
Can you provide an example .xls file?
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

bbimisAuthor Commented:
here is the test file per request
TESTDB.xls
0
matrixnzCommented:
Just add the following to the end of your ItemList Function, this selects the first item in the list i.e. 0
_GUICtrlListBox_SetCurSel($List1, 0)

Open in new window

0
matrixnzCommented:
Question: Does it have to be in a spreadsheet?  Have you considered using an INI file it would make things alot easier?

i.e.

[KVM]
KVM=4857
KVM=4859

[Monitor]
Monitor=5096

[Keyboard]
Keyboard=5198

[Mouse]
Mouse=5199

You can than use something like

IniReadSectionNames to get a list of all Items (They would all be unique)
You can use IniReadSection to get a count of a section
You can use IniWrite('FileName.ini', 'New Item', 'New Item', 'Asset No') to write new section or write to an existing section.

You could also have it export the information to Excel afterwards if you need to.  Just a thought, I just always find ini files easier to control than using COM.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bbimisAuthor Commented:
Matrix I like ur in on idea a lot.  How would I remove the item though?   I'm learning auto it.    
I'll work on the code tomorrow Monday.  Thanks for help hopefully I can ask more questions after giving u points
0
bbimisAuthor Commented:
Thanks
0
matrixnzCommented:
No worries, to remove an item you just use IniDelete.

Cheers
0
bbimisAuthor Commented:
Yeah i was looking at inidelete but it is for a key in the section like
inidelete('section','key');
my issue is the keys are the same the values however are different
i'm needing to maybe do a where ?
like inidelete('KVMS','KVM') where KVM.VALUE = 5589
0
matrixnzCommented:
Sorry the better way to do it would be to use the following format:

[KVM]
5589=KVM
Or
5589=

You don't really need to have a value and key

If you did use the KVM value you could than use something like:
If IniRead('FileName.ini', 'KVM', '5589', 'False') <> 'False' Then
  IniDelete('FileName.ini', 'KVM', 5589')
EndIf

Or something to that effect.
0
bbimisAuthor Commented:
when i do the following: it overwrites the existing key
say i have
[mouse]
Mouse=5555

and i use:
Func insertitem($s_itemvalue, $s_assetvalue)
   
   Iniwrite("inventory.ini",$s_itemvalue,$s_itemvalue,$s_assetvalue)
   
EndFunc

Open in new window

if i make an asset of 7777
it overwrites the mouse to mouse = 7777

woudl it be better to do something like
Iniwrite("inventory.ini",$s_itemvalue,$s_itemvalue&s_assetvalue,$s_assetvalue)

Open in new window


so i would have in the ini file something like this
[mouse]
mouse7777=7777

that way they would be unique
0
bbimisAuthor Commented:
confused on the inidelete though, cause i wouldn't know the section or the key. i would only know the value
For example if i wanted to remove asset 7777
i need to somehow search the ini file for the keyvalue of 7777
and remove the entire key

with inidelete i don't see how since it wants filename,section,key

thanks for the help!
0
matrixnzCommented:
Not sure if you saw my post above, but I assume your asset numbers are all unique?

So would use
[Mouse]
5555=
Or
5555=Mouse

As mentioned above since the Section Name is the description you don't really need to have a value at all.

Hope that makes sense.
0
bbimisAuthor Commented:
no i didn't see you post before. so i think i get what your saying
and then just delete the key in that manner. but how can i know what section it is, because i just want to enter the key number without knowing the section. Sorry :/
0
matrixnzCommented:
Here is some basic code I threw together based on your first post:

#include <ButtonConstants.au3>
#include <ComboConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GUIListBox.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
#include <Excel.au3>
#include <Array.au3>

Global $INI_FILENAME = 'TESTDB.ini' ;This file should already exist

$ARR_ASSETS = IniReadSectionNames($INI_FILENAME)

GUICreate("Stock Room Inventory System", 600, 420)
GUICtrlCreateTab(0, 0, 600, 420)
  $TAB1_SHEET = GUICtrlCreateTabItem("Add Inventory")
    GUICtrlCreateLabel("Item Name", 5, 40, 55, 20)
    $TAB1_COMBO = GUICtrlCreateCombo('', 8, 56, 145, 25, BitOR($CBS_DROPDOWN,$CBS_AUTOHSCROLL))
    GUICtrlSetData($TAB1_COMBO, _ArrayToString($ARR_ASSETS, '|', 1), $ARR_ASSETS[1])

    $TAB1_INPUT = GUICtrlCreateInput("Scan or Enter Asset Number", 336, 64, 153, 21)
    GUICtrlCreateLabel("Asset Number", 336, 48, 70, 17)
    $TAB1_BUTTON = GUICtrlCreateButton("Submit Data", 490, 370, 100, 40)
  $TAB2_SHEET = GUICtrlCreateTabItem("Use Inventory")
    GUICtrlCreateLabel("Please enter Asset Tag to remove", 16, 48, 161, 17)
    $TAB2_INPUT = GUICtrlCreateInput("", 16, 64, 161, 21)
    $TAB2_STATUS = GUICtrlCreateLabel("", 104, 232, 4, 4)
    $TAB2_BUTTON = GUICtrlCreateButton("Process", 490, 370, 100, 40)
  $TAB3_SHEET = GUICtrlCreateTabItem("Reports")
    GUICtrlCreateLabel("Select inventory item", 16, 56, 102, 17)
    $TAB3_LISTVIEW = GUICtrlCreateList("", 16, 72, 321, 97)
    GUICtrlCreateLabel("Number of Items in Stock", 288, 216, 123, 17)
    $TAB3_INPUT = GUICtrlCreateInput("", 424, 212, 121, 21)
    $TAB3_BUTTON = GUICtrlCreateButton("Process", 490, 370, 100, 40)

GUISetState()

While 1
  $Msg = GUIGetMsg()
  Switch $Msg
    Case $GUI_EVENT_CLOSE
      Exit
    Case $TAB1_BUTTON

    Case $TAB2_BUTTON
      If GUICtrlRead($TAB2_INPUT) <> '' Then
        FNC_REMOVEASSETS(GUICtrlRead($TAB2_INPUT))
      EndIf
    Case $TAB3_BUTTON

  EndSwitch
WEnd

Func FNC_REMOVEASSETS($REM_ASSETNUMBER)
  Local $VAR_SECTIONNAMES = IniReadSectionNames($INI_FILENAME)
  For $x = 1 To $VAR_SECTIONNAMES[0]
    If IniRead($INI_FILENAME, $VAR_SECTIONNAMES[$x], $REM_ASSETNUMBER, 'Not Found') <> 'Not Found' Then
      Local $MSG_REMOVEASSETS = MsgBox(36, 'Remove Asset', 'Are you sure you want to remove ' & $REM_ASSETNUMBER & ' from ' & $VAR_SECTIONNAMES[$x] & '?')
      If $MSG_REMOVEASSETS = 6 Then
        IniDelete($INI_FILENAME, $VAR_SECTIONNAMES[$x], $REM_ASSETNUMBER)
        Return
      Else
        ContinueLoop
      EndIf
    EndIf
  Next
EndFunc

Open in new window


INI File
[KVM]
4857=KVM
4859=KVM

[MONITOR]
5096=
[KEYBOARD]
5198=

[MOUSE]
5199=

Open in new window

0
bbimisAuthor Commented:
Thanks a million this works great!!! If i could reward more points i would
0
bbimisAuthor Commented:
what would cause this ?
 i keep getting this error based on the array.au3

array error
0
matrixnzCommented:
It can't read the .ini file or unable to read section names from .ini file

To debug replace the following code:
Global $INI_FILENAME = 'TESTDB.ini' ;This file should already exist

$ARR_ASSETS = IniReadSectionNames($INI_FILENAME)

Open in new window


with

Global $INI_FILENAME = 'TESTDBa.ini' ;This file should already exist
If FileExists($INI_FILENAME) = 0 Then
	MsgBox(16, 'Error:', $INI_FILENAME & ' was not found')
	Exit
EndIf

Global $ARR_ASSETS = IniReadSectionNames($INI_FILENAME)
If @error Then
	MsgBox(16, 'Error:', 'Error reading section names in ' & $INI_FILENAME)
	Exit
EndIf

Open in new window

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Scripting Languages

From novice to tech pro — start learning today.