try..
#include <ButtonConstants.au3>
#include <EditConstants.au3>
#include <GUIConstantsEx.au3>
#include <GuiStatusBar.au3>
#include <GuiIPAddress.au3>
#include <StaticConstants.au3>
#include <TabConstants.au3>
#include <WindowsConstants.au3>
Global $IP
Global $Port
; Connect to IP
$MainForm = GUICreate("Server Starter", 158, 113, 192, 124);
$cl_IP = _GUICtrlIpAddress_Create($MainForm, 16, 16, 130, 21);
_GUICtrlIpAddress_Set($cl_IP, "127.0.0.1")
$cl_Port = GUICtrlCreateInput("1018", 56, 44, 49, 21, BitOR($GUI_SS_DEFAULT_INPUT,$ES_CENTER));
$bStartServer = GUICtrlCreateButton("Connect", 40, 72, 75, 25);
GUISetState(@SW_SHOW);
MsgBox( 0, "Information", "IP Address: " & _GUICtrlIpAddress_Get($cl_IP))
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit;
Case $bStartServer
$IP = GUICtrlRead($cl_IP);
$Port = CheckPort($cl_Port);
GUIDelete($MainForm);
ExitLoop;
EndSwitch
WEnd
Func CheckPort($PortGui)
if (GUICtrlRead($PortGui) >= 0 and GUICtrlRead($PortGui) <= 65535) then
return GUICtrlRead($PortGui);
Else
msgbox(0, "Port is not correct", "Please, pick a different Port");
return -1;
EndIf
EndFunc8)