DTextEntry disappearing when run DButton.DClick

Straight to the point: DTextEntry shows up when I start the script, however when I press one of the buttons (Labelled < and >) it disappears. Its probably something really simple, usually is with me



local Next = nil
local Prev = nil
local Label = nil
local TextBox = nil
local Inbox = {}

local MsgItem = 1

function InboxApp(type, Panel, id)
	if type == 0 then
		Msg("Inbox App Initilised
")
		
		if table.Count(Inbox) == 0 then
			Msg("Inbox Empty
")
			Label = vgui.Create("DLabel", Panel)
			Label:SetText("You have no Messages!")
			Label:SetPos(10,10)
			Label:SizeToContents()
			Panel.Paint  = function()
				surface.SetDrawColor( 0, 0, 0, 255 )
				surface.DrawRect(0,0, Panel:GetWide(), Panel:GetTall() )
			end
			return true;
		end
		Panel.Paint  = function()
			surface.SetDrawColor( 0, 0, 0, 255 )
			surface.DrawRect(0,0, Panel:GetWide(), Panel:GetTall() )
		end
		
		
		Next = vgui.Create("DButton", Panel)
		Prev = vgui.Create("DButton", Panel)
		
		Panel:MakePopup()
		x,y,w,h = Panel:GetBounds()
		Next:SetText(">")
		Next:StretchToParent(145, 102, 0, 0)
		Next.DoClick = function()
			if MsgItem < table.Count(Inbox) then

				MsgItem = MsgItem + 1
				TextBox:SetText(Inbox[MsgItem]["message"])
				print(Inbox[MsgItem]["message"])
				Label:SetText("Msg #"..MsgItem.."      From: "..Inbox[MsgItem]["sender"])
			end
			

			print(MsgItem)
		end
		
		
		Prev:SetText("<")
		Prev:StretchToParent(0, 102, 145, 0)
		Prev.DoClick = function()
			if MsgItem > 1 then
				MsgItem = MsgItem - 1
				print(Inbox[MsgItem]["message"])
				TextBox:SetMultiline(true)
				TextBox:SetPos(22,ScrH()-145)
				TextBox:SetSize(162, 75)
				TextBox:SetText(Inbox[MsgItem]["message"])
				TextBox:AllowInput(false)
				TextBox:SetEditable(false)
				TextBox:MakePopup()
				TextBox:SetParent(Panel)
				Label:SetText("Msg #"..MsgItem.."      From: "..Inbox[MsgItem]["sender"])
			end
			
			print(MsgItem)
		end
		
		TextBox = vgui.Create("DTextEntry", Panel)
		TextBox:SetMultiline(true)
		TextBox:SetPos(22,ScrH()-145)
		TextBox:SetSize(162, 75)
		TextBox:SetText(Inbox[MsgItem]["message"])
		TextBox:AllowInput(false)
		TextBox:SetEditable(false)
		TextBox:MakePopup()
		TextBox:SetParent(Panel)
		


		
		Label = vgui.Create("DLabel", Panel)
		Label:SetText("Msg #"..MsgItem.."      From: "..Inbox[MsgItem]["sender"])
		Label:SizeToContents()
		Label:SetPos(10,10)

			
		return true
	elseif type == 1 then
		--Msg("Blank App Rendering
")
		return true
	elseif type == 2 then
		--Msg("Blank App Closing
")
		return true
	end
end

function RecieveMail(handler, id, encoded, decoded)
	local TempTable = {}
	TempTable["sender"] = ply:GetName()
	TempTable["time"] = os.time()
	TempTable["message"] = encoded["message"]
	print(decoded["message"])
	print(decoded["time"])
	print(decoded["sender"])
	print(table.Count(Inbox)+1)
	Inbox[table.Count(Inbox)+1] = {} 
	print(table.Count(Inbox))
	Inbox[table.Count(Inbox)] = decoded
end
datastream.Hook("RecvSmsMsg", RecieveMail)



If you’re not going to help with the problem stated above, don’t post. Been on enough code help forums to know as soon as you post your code 50people go “theres a better way to do x,y,z”. So unless you think it will actually solve my problem don’t bother. Sorry to sound close minded upfront, but that sort of thing just slows me down.

Thanks in advance :slight_smile:

Dotmister