Jump to content
Sign in to follow this  
youtuber

How do I delete an edit box with ArraySearch and ArrayDelete

Recommended Posts

youtuber
#include <Array.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>

Dim $aArrayedit
$Form1 = GUICreate("Form1", 264, 334, 379, 161)
$Edit1 = GUICtrlCreateEdit("", 40, 32, 185, 225)
GUICtrlSetData(-1, "192.168.1.1" & @CRLF & "192.168.2.1" & @CRLF & "192.168.0.1")
$Button1 = GUICtrlCreateButton("Button1", 96, 272, 65, 33)
GUISetState(@SW_SHOW)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
             _arraysearchdell()
    EndSwitch
WEnd

Func _arraysearchdell()
$aArrayedit = StringSplit(StringStripCR(GUICtrlRead($Edit1)), @LF)
_ArraySearch($aArrayedit)
For $i = UBound($aArrayedit) - 1 To 1 Step -1
   If $aArrayedit[$i] = $aArrayedit[$i - 1] Then 
   _ArrayDelete($aArrayedit, $i)
   ConsoleWrite($aArrayedit &@CRLF)
Next
EndFunc

 

Share this post


Link to post
Share on other sites
AutoBert
  1. a Editbox is a GuiControl, so use GuiControlDelete to delete this Control.
  2. What's the question?

Share this post


Link to post
Share on other sites
youtuber

How to delete the same two?

#include <Array.au3>
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <WindowsConstants.au3>
Dim $aArrayedit
$Form1_1 = GUICreate("Form1", 308, 338, 192, 125)
$Edit1 = GUICtrlCreateEdit("", 24, 32, 121, 225)
GUICtrlSetData(-1, "192.168.1.1" & @CRLF & "192.168.2.1" & @CRLF & "192.168.0.1" & @CRLF & "192.168.1.1" & @CRLF & "192.168.2.1" & @CRLF & "192.168.0.0")
$Edit2 = GUICtrlCreateEdit("" & @CRLF, 160, 32, 129, 225, BitOR($ES_MULTILINE, $ES_AUTOVSCROLL, $WS_VSCROLL))
GUICtrlSetData(-1, "")
$Button1 = GUICtrlCreateButton("Button1", 96, 272, 65, 33)
GUISetState(@SW_SHOW)


While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
             _arraysearchdell()

    EndSwitch
WEnd

Func _arraysearchdell()
$aArrayedit = StringSplit(StringStripCR(GUICtrlRead($Edit1)), @LF)
_ArraySearch($aArrayedit,1)
For $i = UBound($aArrayedit) - 1 To 1 Step -1
    Sleep(500)
   If $aArrayedit[$i] = $aArrayedit[$i - 1] Then _ArrayDelete($aArrayedit, $i)
   GUICtrlSetData($Edit2,  $aArrayedit[$i] & @CRLF, 1)
Next
EndFunc

Share this post


Link to post
Share on other sites
AutoBert

I think simplest way is to use the func _ArrayUnique:

Func _MakeArrayUnique()
    $aArrayedit = StringSplit(StringStripCR(GUICtrlRead($Edit1)), @LF,2)
    $aUnique=_ArrayUnique($aArrayedit)
    _ArraySort($aUnique,0,1)    ;element 0 holds the count of IP's 
    ;_ArrayDisplay($aUnique)
    For $i = 1 To $aUnique[0]
        GUICtrlSetData($Edit2, $aUnique[$i] & @CRLF, 1)
    Next
EndFunc   ;==>_MakeArrayUnique

 

  • Like 1

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.