BPSoftware.com
Home   Utilities   Purchase   FAQ   Support   Contact        
Shareware Utilities
 APrintDirect
 AIconExtract
 AFile Attribute Manager
Freeware Utilities
 AddrMon
 AFileSync
 ASysIcon
 B&P Table Utilities
 BPACLer
 BPSNMPMon
 BPSNMPUtil
 CharCount
 Delphi® Components
 MacAddr
Miscellaneous
 BPSoftware Blog
 Purchase Shareware
 Support

 Subscribe!

Monday, April 10, 2006
Ho Hum

I did receive a couple inquiries about yesterday's post with VB.NET. Well, here goes:

Imports Microsoft.Win32

Public Class frmMain
Const basetzikey = _
"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Time Zones\"


Private Sub frmMain_Load(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles Me.Load

FillComboBox(cbxTimeZone)

End Sub

Private Sub FillComboBox(ByVal cbxCombo As ComboBox)

Dim rootkey As RegistryKey
Dim subkeynames As String()
Dim subkeyname As String

cbxCombo.Items.Clear()
rootkey = Registry.LocalMachine
subkeynames = rootkey.OpenSubKey(basetzikey, False).GetSubKeyNames
For Each subkeyname In subkeynames
cbxCombo.Items.Add(subkeyname.ToString)
Next
End Sub


Private Sub cbxTimeZone_SelectedValueChanged(ByVal sender As Object, _
ByVal e As System.EventArgs) Handles cbxTimeZone.SelectedValueChanged

FillTextEdit(cbxTimeZone.Text, txtOutput)

End Sub

Private Sub FillTextEdit(ByVal timezone As String, _
ByRef txtEdit As TextBox)

Dim sb As New System.Text.StringBuilder
Dim rootkey As RegistryKey
Dim subkeyvalues As String()
Dim subkeyvalue As String
Dim keyname As String
Dim b As Byte()
Dim i As Integer

txtEdit.Clear()

sb.Append(basetzikey)
sb.Append(timezone)
keyname = sb.ToString

' clear stringbuilder
sb.Remove(0, sb.Length)

rootkey = Registry.LocalMachine
subkeyvalues = rootkey.OpenSubKey(keyname, False).GetValueNames
For Each subkeyvalue In subkeyvalues
sb.Remove(0, sb.Length)
sb.Append(subkeyvalue)
sb.Append(": ")
sb.Append(rootkey.OpenSubKey(keyname, False).GetValue(subkeyvalue).ToString)
sb.Append(vbCrLf)
If (subkeyvalue = "TZI") Then
b = rootkey.OpenSubKey(keyname, False).GetValue(subkeyvalue)
i = BitConverter.ToInt32(b, 0)
sb.Append("Bias: ")
sb.Append(i.ToString)
sb.Append(" minutes.")
sb.Append(vbCrLf)
End If

txtEdit.AppendText(sb.ToString)
Next
End Sub
End Class

Labels: , ,

posted by Brad Prendergast at 6:30:00 AM
Comments:
OK, changing Delphi for .Net code to VB.Net code might be considered taking a small backward step. :)
posted by Anonymous Bruce McGee Monday, April 10, 2006 2:23:00 PM  
I can't say that I disagree ;)
posted by Blogger Brad Prendergast Monday, April 10, 2006 2:49:00 PM  
Links to this post:

Create a Link

Recent Posts
 Where is the registry in .NET?
 Managing my Newsgroups
 Meaningful Information
 Rock Paper Scissors
 HTML Element
 ARP! ARP!
 Rightly So
 Easy Does It
 Syndicate Me
 Around the network of silken thread

 Subscribe!


Labels



Archives
 October 2005
 November 2005
 December 2005
 January 2006
 February 2006
 March 2006
 April 2006
 May 2006
 June 2006
 July 2006
 August 2006
 September 2006
 December 2006
 January 2007
 February 2007
 March 2007
 September 2007
 October 2007
 November 2007
 July 2008
 November 2008
Powered by Blogger