Category: VB.NET

Importing data from an Excel sheet

C# Example using System; using System.Collections.Generic; using System.Data; using System.Data.OleDb; using System.Linq; using System.Text; namespace Excel2Table { public class ExcelReader { /// <summary> /// Reads an excel file with OLEDB, and returns a datatable object from the content. The sheet to be imported /// needs to be named “Import” in the excel file. /// </summary> […]

Getting the current date/time from a NIST server

‘ — Get the current time/date from an internet nist server ‘ more timeserver here: http://tf.nist.gov/service/time-servers.html Dim s_checkserver As String = “time.nist.gov” Dim myreader As StreamReader Dim s_timestring As String Try myreader = New StreamReader(New Net.Sockets.TcpClient(s_checkserver, 13).GetStream) s_timestring = myreader.ReadToEnd s_timestring = Trim(LTrim(s_timestring)) Catch ex As Exception ‘ — unable to contact timeserver End End […]

Demonstration of Extending a class

Module Module1 ‘ MCTS70-536/1/1/3 ‘ Extending an existing class ”’ <summary> ”’ A simple base class ”’ </summary> ”’ <remarks></remarks> Public Class Customer Private _naam As String Private _adres As String Private _woonplaats As String Public Property Naam() As String Get Return _naam End Get Set(ByVal value As String) _naam = value End Set End […]

Demonstration of structures and overriding operators

Module Module1 ‘ MCTS70-536-1-1 ‘ VB.NET ‘ Demonstration of a structure with ‘ an operator (+) ‘ an Override (toString) ‘ Public Structure DemoStruct Private _waarde As Integer ‘ — Read and write initial & current value Public Property Value() As Integer Get Return _waarde End Get Set(ByVal value As Integer) _waarde = value End […]

Demonstration of creating an event handler and attaching to an event

Public Class Form1 ‘ MCTS70-536-1-3 ‘ Registering and handling Events Private t As Timer Private p As ProgressBar Private Sub t_Tick(ByVal sender As Object, ByVal e As EventArgs) p.Value += 1 If p.Value = 100 Then p.Value = 1 End If End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load […]

Changing the runtime priority of your application

Module Module1 Sub Main() ‘ — Idle time only, the lowest priority. Use with care as your application could get very little cpu ‘ time allocated on a busy system System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.Idle ‘ — Below normal priority System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.BelowNormal ‘ — Default priority, equal to other programms System.Diagnostics.Process.GetCurrentProcess().PriorityClass = System.Diagnostics.ProcessPriorityClass.Normal ‘ — High […]

Compressing and decompressing files with GZIPStream or Deflatestream

These samples whow how to compress and decompress files with the build in framework methods. For real world applications consider using something like .netzip from codeplex, since the compression quality from the build in methods is limited. Also, the build in methods will allow you to just compress and decompress a single file. Compressing a […]

Next Page »