Sign in to follow this  
Followers 0
tedesco

Cant Clear entries in my form?

13 posts in this topic

how can I clear the entries in my form after I update the info. ??

#include <GuiConstants.au3>
#include <WindowsConstants.au3>
#Include <File.au3>
#Include <GuiListView.au3>
Dim $File_Location = @ScriptDir & "\Address.ini"
Dim $num = 0, $Input_[10], $data_[10]
If Not FileExists($File_Location) Then Set_Ini()

$main = GUICreate(" Client Express", 612, 412, -1, -1);, $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS)
$Group_1 = GUICtrlCreateGroup("Client Panel", 10, 10, 250, 390)
$Group_2 = GUICtrlCreateGroup("Client Information", 280, 10, 320, 390)
$Group_3 = GUICtrlCreateGroup("Search", 20, 30, 230, 140)
$Group_4 = GUICtrlCreateGroup("Controls", 20, 180, 230, 210)
$Combo_3 = GUICtrlCreateCombo("Search by...", 80, 50, 100, 21)
$Input_11 = GUICtrlCreateInput("Search Criteria", 45, 85, 180, 20)
$Label_10 = GUICtrlCreateLabel("Client #: " & $num, 440, 30, 120, 25)
GUICtrlSetFont(-1, 9.5, 550)
$Label_12 = GUICtrlCreateLabel("Name", 300, 40, 70, 20)
$Input_[1] = GUICtrlCreateInput("", 300, 60, 280, 20)
$Label_14 = GUICtrlCreateLabel("Address", 300, 90, 90, 20)
$Label_15 = GUICtrlCreateLabel("Street Name", 380, 90, 140, 20)
$Input_[2] = GUICtrlCreateInput("", 300, 110, 70, 20)
$Input_[3] = GUICtrlCreateInput("", 380, 110, 200, 20)
$Label_18 = GUICtrlCreateLabel("City", 300, 140, 50, 20)
$Label_19 = GUICtrlCreateLabel("Phone", 430, 140, 120, 20)
$Input_[4] = GUICtrlCreateInput("", 300, 160, 110, 20)
$Input_[5] = GUICtrlCreateInput("", 430, 160, 150, 20)
$Label_22 = GUICtrlCreateLabel("State", 300, 190, 70, 20)
$Label_23 = GUICtrlCreateLabel("Zip + 4", 390, 190, 110, 20)
$Input_[6] = GUICtrlCreateInput("", 300, 210, 80, 20)
$Input_[7] = GUICtrlCreateInput("", 390, 210, 190, 20)
$Edit_26 = GUICtrlCreateLabel("Notes", 300, 240, 80, 20)
$Edit_26 = GUICtrlCreateEdit("", 300, 260, 280, 120)
; controls
$Button_9 = GUICtrlCreateButton("Start Search", 45, 120, 180, 30)
$Button_10 = GUICtrlCreateButton("Add Client", 45, 210, 180, 30)
$Button_11 = GUICtrlCreateButton("Update Client", 45, 250, 180, 30)
$Button_12 = GUICtrlCreateButton("View All Client", 45, 290, 180, 30)
$Button_13 = GUICtrlCreateButton("Close Client Express", 45, 330, 180, 30)
GUISetState()
GUICtrlSetData($Combo_3, "Client #|Name|Address|Street|City|Phone|Zip+4|Notes")
$viewer = GUICreate("CLient Express", 602, 432, 5, 5,$WS_BORDER, -1, $main)
$Listview = GUICtrlCreateListView("Client #|Name|Address|Street|City|Phone|Zip+4|Notes", 10, 10, 582, 352)
$Closer = GUICtrlCreateButton("Close", 230, 365, 180, 30)
GUISetState(@SW_HIDE)
While 1
$msg = GUIGetMsg()
Select
     Case $msg = $GUI_EVENT_CLOSE Or $msg = $Button_13
         ExitLoop
     Case $msg = $Button_9
         Set_Customers()
     Case $msg = $Button_10
         Add_Customer()
GUICtrlSetState(@sw_show,$Main)
     Case $msg = $Button_11
         Update_Customer()
     Case $msg = $Button_12
         GUISetState(@SW_SHOW, $viewer)
         Get_List()
     Case $msg = $Closer
         _GUICtrlListView_DeleteAllItems($listview)
         GUISetState(@SW_HIDE, $viewer)
         GUISetState(@SW_SHOW, $main)
     ;;;
EndSelect
WEnd
Exit
; --------------------------- Functions -----------------
Func Set_Ini()
FileWriteLine($File_Location, "[Address]")

EndFunc ;==>Set_Ini
Func Set_Customers()
$num = 0
$temp_info = GUICtrlRead($Combo_3)
If $temp_info = "Search by..." Or $temp_info = "" Then Return
If $temp_info = "Name" Then $temp_search = 1
If $temp_info = "Address" Then $temp_search = 2
If $temp_info = "Street" Then $temp_search = 3
If $temp_info = "City" Then $temp_search = 4
If $temp_info = "Phone" Then $temp_search = 5
If $temp_info = "Zip+4" Then $temp_search = 7
If $temp_info = "Notes" Then $temp_search = 8
If $temp_info = "Client #" Then
     $num = GUICtrlRead($Input_11)
     Get_CNumber($num)
     Return
EndIf
$temp_find = GUICtrlRead($Input_11)
$length = _FileCountLines($File_Location)
For $x = 1 To $length - 1
     $temp_file = IniRead($File_Location, "Address", $x, "Not Found")
     If $temp_file = "Not Found" Then
         MsgBox(0, "", "No Files\Folders Found.")
         Return
     EndIf
     $temp_split = StringSplit($temp_file, ",")
     If StringInStr($temp_split[$temp_search], $temp_find) Then
         For $t = 1 To $temp_split[0] -1
             GUICtrlSetData($Input_[$t], $temp_split[$t])
             $num = $x
         Next
         GUICtrlSetData($Edit_26, $temp_split[8])
         GUICtrlSetData($Label_10, "Customer #: " & $num)
         Return
     EndIf
Next
EndFunc ;==>Set_Customers
Func Get_CNumber($x)
$temp_file = IniRead($File_Location, "Address", $x, "Not Found")
If $temp_file = "Not Found" Then
     MsgBox(0, "", "No Files\Folders Found.")
     Return
EndIf
$temp_split = StringSplit($temp_file, ",")
For $t = 1 To $temp_split[0] - 1
     GUICtrlSetData($Input_[$t], $temp_split[$t])
     $num = $x
Next
GUICtrlSetData($Edit_26, $temp_split[8])
GUICtrlSetData($Label_10, "Customer #: " & $num)
Return
EndFunc ;==>Get_CNumber
Func Get_List()
$length = _FileCountLines($File_Location)
For $x = 1 To $length - 1
     $temp_file = IniRead($File_Location, "Address", $x, "Not Found")
     If $temp_file = "Not Found" Then Return
     $temp_split = StringSplit($temp_file, ",")
     GUICtrlCreateListViewItem( $x & "|" & $temp_split[1] & "|" & $temp_split[2] & "|" & $temp_split[3] & "|" & $temp_split[4] & "|" & $temp_split[5] & "|" & $temp_split[6] & "|" & $temp_split[7] & "|" & $temp_split[8] & "|" ,$listview)
Next
EndFunc
Func Add_Customer()
$length = _FileCountLines($File_Location)
IniWrite($File_Location, "Address", $length, GUICtrlRead($Input_[1]) &","& GUICtrlRead($Input_[2])&","& GUICtrlRead($Input_[3])&","& GUICtrlRead($Input_[4])&","& GUICtrlRead($Input_[5])&","& GUICtrlRead($Input_[6])&","&GUICtrlRead($Input_[7])&","& GUICtrlRead($Edit_26))
     GUICtrlSetData($Label_10, "Customer #: " & $length)
EndFunc
Func UpDate_Customer()
$num = StringTrimLeft(GUICtrlRead($Label_10), 12)
IniWrite($File_Location, "Address", $num, GUICtrlRead($Input_[1]) &","& GUICtrlRead($Input_[2])&","& GUICtrlRead($Input_[3])&","& GUICtrlRead($Input_[4])&","& GUICtrlRead($Input_[5])&","& GUICtrlRead($Input_[6])&","&GUICtrlRead($Input_[7])&","& GUICtrlRead($Edit_26))
EndFunc

Share this post


Link to post
Share on other sites



Can you be a bit more clear as to what the problem is, and what you've tried?


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

When enter information into the form I click Add client. The information gets recoreded but it also just stays in the form window. I have tried several things to clear out the data upon clicking the Addclient button but nothing worked.

Share this post


Link to post
Share on other sites

Use something like

GUICtrlSetData($Input_[7],"")
to clear the input.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Try this modification:

Func Add_Customer()
     $length = _FileCountLines($File_Location)
     IniWrite($File_Location, "Address", $length, GUICtrlRead($Input_[1]) & "," & GUICtrlRead($Input_[2]) & "," & GUICtrlRead($Input_[3]) & "," & GUICtrlRead($Input_[4]) & "," & GUICtrlRead($Input_[5]) & "," & GUICtrlRead($Input_[6]) & "," & GUICtrlRead($Input_[7]) & "," & GUICtrlRead($Edit_26))
     GUICtrlSetData($Label_10, "Customer #: " & $length)
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
     For $I = 1 To 7
          GUICtrlSetData($Input_[$I], "")
     Next
;<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
EndFunc   ;==>Add_Customer

You should probably also update the UpdateCustomer function the same way.


If I posted any code, assume that code was written using the latest release version unless stated otherwise. Also, if it doesn't work on XP I can't help with that because I don't have access to XP, and I'm not going to.
Give a programmer the correct code and he can do his work for a day. Teach a programmer to debug and he can do his work for a lifetime - by Chirag Gude
How to ask questions the smart way!

I hereby grant any person the right to use any code I post, that I am the original author of, on the autoitscript.com forums, unless I've specifically stated otherwise in the code or the thread post. If you do use my code all I ask, as a courtesy, is to make note of where you got it from.

Back up and restore Windows user files _Array.au3 - Modified array functions that include support for 2D arrays.  -  ColorChooser - An add-on for SciTE that pops up a color dialog so you can select and paste a color code into a script.  -  Customizable Splashscreen GUI w/Progress Bar - Create a custom "splash screen" GUI with a progress bar and custom label.  -  _FileGetProperty - Retrieve the properties of a file  -  SciTE Toolbar - A toolbar demo for use with the SciTE editor  -  GUIRegisterMsg demo - Demo script to show how to use the Windows messages to interact with controls and your GUI.  -   Latin Square password generator

Share this post


Link to post
Share on other sites

Ok, that clears out one field but not all of them. What is the signifigence of the value 7?

Share this post


Link to post
Share on other sites

#7 ·  Posted (edited)

You created an array Input_ that holds the IDs of all Input Controls. You used 7 Input controls and assigned the IDs to elements 1 to 7 of the array.

For $I = 1 To 7
    GUICtrlSetData($Input_[$I], "")
Next
resets this 7 Input controls.

Edited by water

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

BrewManNH, here is the error I get now:

I:autoit examplesClient Express.au3 (65) : ==> Error in expression.:

GUICtrlSetData($Input_[],"")

GUICtrlSetData($Input_[^ ERROR

Share this post


Link to post
Share on other sites

You missed the variable. It has to be

GUICtrlSetData($Input_[$i],"")


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

But i do have that in the script. The error takes it out like it dont see it?

Share this post


Link to post
Share on other sites

Please press Ctrl+F5 in SciTE to do a syntax check and post the result.


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

Share this post


Link to post
Share on other sites

Sorry, I figured it out. Higher up in the code I had that statement and forgot to take ti out. Thank you for all your help and patients. You guys are great! These forums are priceless!

Share this post


Link to post
Share on other sites

Glad to be of service :D


My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2017-04-18 - Version 1.4.8.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX (NEW 2017-02-27 - Version 1.3.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2015-04-01 - Version 0.4.0.0) - Download - General Help & Support - Example Scripts
Excel - Example Scripts - Wiki
Word - Wiki
PowerPoint (2015-06-06 - Version 0.0.5.0) - Download - General Help & Support

Tutorials:
ADO - Wiki

 

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