Ok so you boot up a textbox class. Getting this in, in my eyes
merely cosmetic. I used a module named programFunction with a string named tboxtext.
A Couple of Functions that take a string argument. They do all the checking, making
sure it is what was either in file or typed in. Then an event in the main form named
appendtext args are object and eventargs.(the norm?) Next a sub to handle the event.
Once done there inside handled sub. Make a for each for the string in the module.
inside the foreach append the variable for the statement and the new line property in
enviroment. So Above the for each you should have a line indicator appending.
For Example...
Imports MySql.Data.MySqlClient
Public Class Form1
Private Event appendText(sender As Object, e As EventArgs)
Private Event programTime(sender As Object, e As EventArgs)
Private timeofProgram As Single
Private currentCommand, previousCommand As String
Private Const meText As String = "Form of Digital"
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
tboxText = ""
Timer1.Interval = 60.0F
Timer1.Start()
GroupBox1.Anchor = AnchorStyles.Right
Tbox1.Anchor = AnchorStyles.Top
Inputbox1.Anchor = AnchorStyles.Top
Digitalabel1.Anchor = AnchorStyles.Top
''Mysql initalization here
ProgramFunction.initMySql()
''End Mysql initialization
''Init logger
''ProgramFunction.initLogger()
End Sub
Private Sub elapseProgramTime() Handles MyClass.programTime
If IsNothing(timeofProgram) Then
Environment.Exit(0)
ElseIf timeofProgram >= 100.0F Then
timeofProgram = 0.0F
Else
timeofProgram += 1.0F
End If
End Sub
Private Sub tboxAppend() Handles MyClass.appendText
Me.Tbox1.AppendText(ProgramFunction.lineIndicator)
For Each s As String In ProgramFunction.tboxText
Me.Tbox1.AppendText(s)
Next
Me.Tbox1.AppendText(Environment.NewLine)
If ProgramFunction.hasShown = True Then
Me.Tbox1.AppendText(ProgramFunction.lineIndicator)
For Each userData As Object In ProgramFunction.userData
Try
Me.Tbox1.AppendText(CStr(userData))
Catch ex As NullReferenceException
Me.Tbox1.AppendText("Less than 25 results. Exiting Sub..")
ProgramFunction.hasShown = False
Exit Sub
End Try
Next
Me.Tbox1.AppendText(Environment.NewLine)
ProgramFunction.hasShown = False
End If
End Sub
Private Sub Digitalbutton1_Click(sender As Object, e As EventArgs) Handles Digitalbutton1.Click
ProgramFunction.displayUsers()
RaiseEvent appendText(Me, New EventArgs)
End Sub
Protected Overrides Sub WndProc(ByRef m As Message)
MyBase.WndProc(m)
Select Case m.Msg
Case ProgramFunction.WndMsg.WM_ACTIVATE
Case ProgramFunction.WndMsg.WM_KEYDOWN
FindForm()
End Select
End Sub
Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick
RaiseEvent programTime(Me, New EventArgs())
End Sub
Private Sub AboutToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles AboutToolStripMenuItem.Click
ProgramFunction.tboxText = "Xenos GM Tool"
RaiseEvent appendText(Me, New EventArgs())
End Sub
Private Sub Form1_Resize(sender As Object, e As EventArgs) Handles MyBase.Resize
Return
End Sub
Private Sub Digitalbutton4_Click(sender As Object, e As EventArgs) Handles Digitalbutton4.Click
ProgramFunction.userlist.Clear()
tboxText = ProgramFunction.updateUsers() + Environment.NewLine
RaiseEvent appendText(Me, New EventArgs)
End Sub
Private Sub Digitalbutton5_Click(sender As Object, e As EventArgs) Handles Digitalbutton5.Click
ProgramFunction.tboxText = ""
End Sub
Private Sub Inputbox1_KeyDown(sender As Object, e As KeyEventArgs) Handles Inputbox1.KeyDown
If e.KeyCode = Keys.Enter Then
currentCommand = Inputbox1.Text
tboxText = "Command" + Inputbox1.Text + "has been entered use the ok button to confirm."
RaiseEvent appendText(Me, New EventArgs)
tboxText = ""
If currentCommand = "set" Then
Inputbox1.Clear()
tboxText = "Set user name to find."
RaiseEvent appendText(Me, New EventArgs)
tboxText = "Clearing textbox click ok when name is entered."
RaiseEvent appendText(Me, New EventArgs)
tboxText = ""
End If
End If
End Sub
Private Sub Digitalbutton2_Click(sender As Object, e As EventArgs) Handles Digitalbutton2.Click
If previousCommand > "" Then
previousCommand = ""
previousCommand = currentCommand
End If
If currentCommand = "help" Then
tboxText = "Use the ok button to confirm commands entered"
RaiseEvent appendText(Me, New EventArgs)
tboxText = ""
tboxText = "The clear button clears the main helper string for the append text event, saves room in program"
RaiseEvent appendText(Me, New EventArgs)
tboxText = ""
tboxText = "So after using any querys remember to use the clear buttons or you will have a mixed up query or worse an error."
RaiseEvent appendText(Me, New EventArgs)
tboxText = ""
End If
If currentCommand = "accounts" Then
End If
If currentCommand = "set" Then
tboxText = Inputbox1.Text
End If
If currentCommand = "users" Then
For x = 0 To userlist.Count
tboxText.Insert(x, userlist.ElementAt(x))
Next
RaiseEvent appendText(Me, New EventArgs)
End If
End Sub
Private Sub Digitalbutton3_Click(sender As Object, e As EventArgs) Handles Digitalbutton3.Click
previousCommand = currentCommand
currentCommand = ""
End Sub
Private Sub Digitalbutton6_Click(sender As Object, e As EventArgs) Handles Digitalbutton6.Click
Environment.Exit(0)
End Sub
Private Sub Digitalbutton7_Click(sender As Object, e As EventArgs) Handles Digitalbutton7.Click
ProgramFunction.userbyName()
RaiseEvent appendText(Me, New EventArgs)
End Sub
End Class
Imports MySql.Data.MySqlClient
Imports System.Collections.Generic
Module ProgramFunction
#Region "Main Form Initialization"
Dim form1 As New Form1
Private conString As String
Private sqlcon As MySqlConnection
Private sqlcommand As MySqlCommand
Const run As String = "running"
Const formWidth As Integer = 800
Const formHeight As Integer = 450
Public Enum WndMsg
WM_ACTIVATE = &H6
WM_ACTIVATEAPP = &H1C
WM_AFXFIRST = &H360
WM_AFXLAST = &H37F
WM_APP = &H8000
WM_ASKCBFORMATNAME = &H30C
WM_CANCELJOURNAL = &H4B
WM_CANCELMODE = &H1F
WM_CAPTURECHANGED = &H215
WM_CHANGECBCHAIN = &H30D
WM_CHANGEUISTATE = &H127
WM_CHAR = &H102
WM_CHARTOITEM = &H2F
WM_CHILDACTIVATE = &H22
WM_CLEAR = &H303
WM_CLOSE = &H10
WM_COMMAND = &H111
WM_COMPACTING = &H41
WM_COMPAREITEM = &H39
WM_CONTEXTMENU = &H7B
WM_COPY = &H301
WM_COPYDATA = &H4A
WM_CREATE = &H1
WM_CTLCOLORBTN = &H135
WM_CTLCOLORDLG = &H136
WM_CTLCOLOREDIT = &H133
WM_CTLCOLORLISTBOX = &H134
WM_CTLCOLORMSGBOX = &H132
WM_CTLCOLORSCROLLBAR = &H137
WM_CTLCOLORSTATIC = &H138
WM_CUT = &H300
WM_DEADCHAR = &H103
WM_DELETEITEM = &H2D
WM_DESTROY = &H2
WM_DESTROYCLIPBOARD = &H307
WM_DEVICECHANGE = &H219
WM_DEVMODECHANGE = &H1B
WM_DISPLAYCHANGE = &H7E
WM_DRAWCLIPBOARD = &H308
WM_DRAWITEM = &H2B
WM_DROPFILES = &H233
WM_ENABLE = &HA
WM_ENDSESSION = &H16
WM_ENTERIDLE = &H121
WM_ENTERMENULOOP = &H211
WM_ENTERSIZEMOVE = &H231
WM_ERASEBKGND = &H14
WM_EXITMENULOOP = &H212
WM_EXITSIZEMOVE = &H232
WM_FONTCHANGE = &H1D
WM_GETDLGCODE = &H87
WM_GETFONT = &H31
WM_GETHOTKEY = &H33
WM_GETICON = &H7F
WM_GETMINMAXINFO = &H24
WM_GETOBJECT = &H3D
WM_GETTEXT = &HD
WM_GETTEXTLENGTH = &HE
WM_HANDHELDFIRST = &H358
WM_HANDHELDLAST = &H35F
WM_HELP = &H53
WM_HOTKEY = &H312
WM_HSCROLL = &H114
WM_HSCROLLCLIPBOARD = &H30E
WM_ICONERASEBKGND = &H27
WM_IME_CHAR = &H286
WM_IME_COMPOSITION = &H10F
WM_IME_COMPOSITIONFULL = &H284
WM_IME_CONTROL = &H283
WM_IME_ENDCOMPOSITION = &H10E
WM_IME_KEYDOWN = &H290
WM_IME_KEYLAST = &H10F
WM_IME_KEYUP = &H291
WM_IME_NOTIFY = &H282
WM_IME_REQUEST = &H288
WM_IME_SELECT = &H285
WM_IME_SETCONTEXT = &H281
WM_IME_STARTCOMPOSITION = &H10D
WM_INITDIALOG = &H110
WM_INITMENU = &H116
WM_INITMENUPOPUP = &H117
WM_INPUTLANGCHANGE = &H51
WM_INPUTLANGCHANGEREQUEST = &H50
WM_KEYDOWN = &H100
WM_KEYFIRST = &H100
WM_KEYLAST = &H108
WM_KEYUP = &H101
WM_KILLFOCUS = &H8
WM_LBUTTONDBLCLK = &H203
WM_LBUTTONDOWN = &H201
WM_LBUTTONUP = &H202
WM_MBUTTONDBLCLK = &H209
WM_MBUTTONDOWN = &H207
WM_MBUTTONUP = &H208
WM_MDIACTIVATE = &H222
WM_MDICASCADE = &H227
WM_MDICREATE = &H220
WM_MDIDESTROY = &H221
WM_MDIGETACTIVE = &H229
WM_MDIICONARRANGE = &H228
WM_MDIMAXIMIZE = &H225
WM_MDINEXT = &H224
WM_MDIREFRESHMENU = &H234
WM_MDIRESTORE = &H223
WM_MDISETMENU = &H230
WM_MDITILE = &H226
WM_MEASUREITEM = &H2C
WM_MENUCHAR = &H120
WM_MENUCOMMAND = &H126
WM_MENUDRAG = &H123
WM_MENUGETOBJECT = &H124
WM_MENURBUTTONUP = &H122
WM_MENUSELECT = &H11F
WM_MOUSEACTIVATE = &H21
WM_MOUSEFIRST = &H200
WM_MOUSEHOVER = &H2A1
WM_MOUSELAST = &H20D
WM_MOUSELEAVE = &H2A3
WM_MOUSEMOVE = &H200
WM_MOUSEWHEEL = &H20A
WM_MOUSEHWHEEL = &H20E
WM_MOVE = &H3
WM_MOVING = &H216
WM_NCACTIVATE = &H86
WM_NCCALCSIZE = &H83
WM_NCCREATE = &H81
WM_NCDESTROY = &H82
WM_NCHITTEST = &H84
WM_NCLBUTTONDBLCLK = &HA3
WM_NCLBUTTONDOWN = &HA1
WM_NCLBUTTONUP = &HA2
WM_NCMBUTTONDBLCLK = &HA9
WM_NCMBUTTONDOWN = &HA7
WM_NCMBUTTONUP = &HA8
WM_NCMOUSEHOVER = &H2A0
WM_NCMOUSELEAVE = &H2A2
WM_NCMOUSEMOVE = &HA0
WM_NCPAINT = &H85
WM_NCRBUTTONDBLCLK = &HA6
WM_NCRBUTTONDOWN = &HA4
WM_NCRBUTTONUP = &HA5
WM_NCXBUTTONDBLCLK = &HAD
WM_NCXBUTTONDOWN = &HAB
WM_NCXBUTTONUP = &HAC
WM_NCUAHDRAWCAPTION = &HAE
WM_NCUAHDRAWFRAME = &HAF
WM_NEXTDLGCTL = &H28
WM_NEXTMENU = &H213
WM_NOTIFY = &H4E
WM_NOTIFYFORMAT = &H55
WM_NULL = &H0
WM_PAINT = &HF
WM_PAINTCLIPBOARD = &H309
WM_PAINTICON = &H26
WM_PALETTECHANGED = &H311
WM_PALETTEISCHANGING = &H310
WM_PARENTNOTIFY = &H210
WM_PASTE = &H302
WM_PENWINFIRST = &H380
WM_PENWINLAST = &H38F
WM_POWER = &H48
WM_POWERBROADCAST = &H218
WM_PRINT = &H317
WM_PRINTCLIENT = &H318
WM_QUERYDRAGICON = &H37
WM_QUERYENDSESSION = &H11
WM_QUERYNEWPALETTE = &H30F
WM_QUERYOPEN = &H13
WM_QUEUESYNC = &H23
WM_QUIT = &H12
WM_RBUTTONDBLCLK = &H206
WM_RBUTTONDOWN = &H204
WM_RBUTTONUP = &H205
WM_RENDERALLFORMATS = &H306
WM_RENDERFORMAT = &H305
WM_SETCURSOR = &H20
WM_SETFOCUS = &H7
WM_SETFONT = &H30
WM_SETHOTKEY = &H32
WM_SETICON = &H80
WM_SETREDRAW = &HB
WM_SETTEXT = &HC
WM_SETTINGCHANGE = &H1A
WM_SHOWWINDOW = &H18
WM_SIZE = &H5
WM_SIZECLIPBOARD = &H30B
WM_SIZING = &H214
WM_SPOOLERSTATUS = &H2A
WM_STYLECHANGED = &H7D
WM_STYLECHANGING = &H7C
WM_SYNCPAINT = &H88
WM_SYSCHAR = &H106
WM_SYSCOLORCHANGE = &H15
WM_SYSCOMMAND = &H112
WM_SYSDEADCHAR = &H107
WM_SYSKEYDOWN = &H104
WM_SYSKEYUP = &H105
WM_TCARD = &H52
WM_TIMECHANGE = &H1E
WM_TIMER = &H113
WM_UNDO = &H304
WM_UNINITMENUPOPUP = &H125
WM_USER = &H400
WM_USERCHANGED = &H54
WM_VKEYTOITEM = &H2E
WM_VSCROLL = &H115
WM_VSCROLLCLIPBOARD = &H30A
WM_WINDOWPOSCHANGED = &H47
WM_WINDOWPOSCHANGING = &H46
WM_WININICHANGE = &H1A
WM_XBUTTONDBLCLK = &H20D
WM_XBUTTONDOWN = &H20B
WM_XBUTTONUP = &H20C
End Enum
Private Function initForm1() As Boolean
form1.Width = formWidth
form1.Height = formHeight
form1.Text = "Xeno.VB"
Application.Run(form1)
Return True
End Function
Sub Main()
initForm1()
While run = "running"
Application.DoEvents()
If canresizeForm() = True Then
form1.Size = New Size(formWidth, formHeight)
Else
form1.Size = New Size(formWidth, formHeight)
End If
End While
End Sub
Function canresizeForm() As Boolean
If IsNothing(formWidth) Then
Return False
End If
If IsNothing(formHeight) Then
Return False
End If
Return True
End Function
#End Region
#Region "InitializeMysql()"
Private userID As Integer
Private dt As DataTable
Public userlist As List(Of String)
Public hasShown As Boolean
Public Function initMySql() As Boolean
conString = "Server=localhost;Database=netvx;Uid=root;Pwd=mysql;"
sqlcon = New MySqlConnection(conString)
sqlcommand = New MySqlCommand("SELECT * FROM users", sqlcon)
dt = New DataTable("users", "vxusers")
userlist = New List(Of String)
hasShown = False
Return True
End Function
#End Region
#Region "Tbox Functions"
Public Const lineIndicator As String = ">>"
Public tboxText As String
Public userData(25) As String
Private Function checkLine(line As String) As String
If line = "" Or IsNothing(line) Or IsNothing(lineIndicator) Then
Return "Invalid Command"
End If
Return "Command Successfull"
End Function
Public Function displayUsers() As String()
sqlcon.Open()
sqlcommand.ExecuteNonQuery()
Dim dr As MySqlDataReader = sqlcommand.ExecuteReader()
While dr.Read()
If dr.HasRows Then
For x = 0 To dr.FieldCount - 1
userData.SetValue(CStr(dr.Item(x)), x)
userlist.Add(CStr(dr.Item(x)))
Next
Else
Return {"No rows found."}
End If
End While
sqlcon.Close()
hasShown = True
Return userData
End Function
Public Function userbyName() As String()
sqlcon.Open()
sqlcommand.CommandText = "Select (name) FROM users value =" + tboxText
sqlcommand.ExecuteNonQuery()
Dim dr As MySqlDataReader = sqlcommand.ExecuteReader()
While dr.Read()
If dr.HasRows Then
For x = 0 To dr.FieldCount - 1
userData.SetValue(CStr(dr.Item(x)), x)
Next
Else
Return {"No Rows Found."}
End If
End While
sqlcon.Close()
Return userData
End Function
Public Function updateUsers() As String
userData = Nothing
Return "User list cleared!"
End Function
Public Sub tboxWrite()
If IsNothing(WriteTextBox) Then
End If
End Sub
Public Function WriteTextBox() As String
Return checkLine(tboxText)
End Function
#End Region
#Region "DigitalLog"
Private fs As IO.FileStream
Private logCount As Integer
Private data As String
Private buffer As Byte
Public Function initLogger() As Boolean
logCount = 0
fs = IO.File.Create(Application.StartupPath + "/Log/" + "log" + logCount.ToString())
logCount += 1
Return True
End Function
#End Region
End Module