Showing posts with label vb. Show all posts
Showing posts with label vb. Show all posts

Tuesday, 23 February 2016

How to Read Event Viewer in VB.NETIn Feburary 2016 23,

In Feburary 2016 23,
Start Microsoft Visual Basic Express and click 'New Project...' on the left pane of your screen. Double-click 'Windows Forms Application' to start your new project.
Double-click 'Button' on the 'Tools' pane to create a new button. Double-click 'ListBox' on the 'Tools' pane to create a new list box control. Double-click 'Button1' to open the 'Form1.vb' module.
Press 'Ctrl+A' and press 'Delete' to delete all code.
Copy and paste the following code to your 'Form1.vb' module.Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.ClickDim eventLogApp As New System.Diagnostics.EventLog('Application')Dim eventLogEntry As System.Diagnostics.EventLogEntryDim eventCntr As Integer = 1For Each eventLogEntry In eventLogApp.EntriesMe.ListBox1.Items.Add('Event Number:' & eventCntr)Me.ListBox1.Items.Add(eventLogEntry.EntryType.ToString)Me.ListBox1.Items.Add(eventLogEntry.TimeGenerated.ToString)Me.ListBox1.Items.Add(eventLogEntry.Source.ToString)Me.ListBox1.Items.Add(eventLogEntry.Category.ToString)Me.ListBox1.Items.Add(eventLogEntry.EventID.ToString)Me.ListBox1.Items.Add(eventLogEntry.MachineName.ToString)Me.ListBox1.Items.Add(eventLogEntry.Message.ToString)Me.ListBox1.Items.Add('-----------------------------------------------')eventCntr = eventCntr + 1Me.ListBox1.Refresh()NextEnd Sub
End Class
Start your program by pressing 'F5' and then clicking 'Button1' to display event log entries through a list box.
In Feburary 2016 23,

Sunday, 7 February 2016

How to Add Fields to a Table in Access with Visual BasicIn Feburary 2016 07,

In Feburary 2016 07,
Open Microsoft Visual Basic Express, and click 'New Project...' in the left pane of your screen. Double-click 'Console Application.' Press 'Ctrl' and 'A' and then press 'Delete' to remove the current code.
Copy and paste the following code to your 'Module1.vb' module to execute a query and add two fields to the 'Products' table in the Northwind database.Imports System.Data.OleDbModule Module1
Sub Main()Dim northwindConn As OleDbConnectionDim sqlComm As OleDbCommandDim strSQL As StringnorthwindConn = New OleDbConnection('Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\ Northwind 2007.accdb;')northwindConn.Open()strSQL = 'ALTER TABLE Products ' & _'ADD COLUMN Product_I Text (30), Product_II Text (30);'sqlComm = New OleDbCommand(strSQL, northwindConn)sqlComm.ExecuteNonQuery()MsgBox('Added two fields successfully to the Products table.')northwindConn.Close()End Sub
End Module
Edit the following line of code and type the path to your database:OleDbConnection('Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\ Northwind 2007.accdb;')Press 'F5' to run your program.
In Feburary 2016 07,