|
Hi,
I've been trying to list all the registry values in a certain key, but I keep getting an "Object Reference Not Set to an Instance of an Object" error on the first line. My code is:
Dim GetValues As Microsoft.Win32.RegistryKey = My.Computer.Registry.LocalMachine.OpenSubKey("\Software\Microsoft\Windows\CurrentVersion\Run")
For Each ValueKey As String In GetValues.GetValueNames
Dim ItemRead As String = My.Computer.Registry.GetValue(GetValues.ToString, ValueKey, "")
'Add Items to ListView
GlobalList.Items.Add(ItemRead)
Next
Is there maybe a better way to list the registry values than the way I've been trying? Nothing seems to work.
Thanks for the help.
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
Take the slash in front of "\Software\..." out. It should be "Software\...".
Your code is ASSUMING that OpenSubKey is actually returning something. It'll help if you checked GetValues (that's a bad variable name BTW) for an object before you try and use it in your loop. You might also want to get the values from the Run key you opened and not from the root of Local Machine. Also, you have to close the key you opened when you're done with it.
Dim runKey As RegistryKey = Registry.LocalMachine.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Run")
If Not runKey Is Nothing Then
For Each valueName As String In runKey.GetValueNames()
Dim itemValue As String = runKey.GetValue(valueName, "").ToString()
Debug.WriteLine(String.Format("{0} : {1}", valueName, itemValue))
Next
runKey.Close()
End If
Dave Kreskowiak
Microsoft MVP - Visual Basic
|
|
|
|
|
Thanks for the help!
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
hi guys does anyone know how to list all the files that are in the bin folder that are xls format(.xls) to a listbox i am trying to learn how to do this so could any one teach =P
|
|
|
|
|
Try this:
For Each xslFile As String In My.Computer.FileSystem.GetFiles(My.Computer.FileSystem.CurrentDirectory, FileIO.SearchOption.SearchTopLevelOnly, "*.xsl")
MsgBox(xslFile)
Next
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
Have your folder as a string.
Dim Folder as string = 'your project directory
Dim file as system.io.fileinfo
dim fol as new system.io.directoryinfo(folder)
for each file in fol.getfiles(".xsl")
listbox1.items.add(file)
next
Posted by The ANZAC
|
|
|
|
|
I posted this question on the ADO.NET board, but the only reply I got was that I need to check my Update code.
I have an Access database with a Date/Time column. I used the VS.NET forms designer to create an OleDbDataAdapter and DataSet from the datasource. The DataSet created has the Date/Time column with a DateTime type as expected. The Fill and Update methods work properly without exception. However, after an insert or update, the data that actually gets stored to the database has a time of 12:00:00 AM, requardless of the time I specified while running the application.
One solution I have thought of, but not tried, is to change all DateTime column types in the Typed-DataSet to OleDb.Date.
Thanks,
Scott Page
"Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem."
( President Ronald Reagan)
|
|
|
|
|
I'm working on an ASP.NET 2.0 web application (VB) that needs to be internationalized. Extended ResourceProviderFactory and IResourceProvider and have an AccessResourceHelper to get the resources from the Access DB. Most of the resourceses works except for the 'Implicit' ones. I must be missing something.
If you need to see my code let me know..
Will post it.
Any help will be greatly appreciated,
HR
|
|
|
|
|
Below is the code I have but nothing appears on the form?
Public Class Form1
Dim WithEvents MyLabel As New Label
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
With MyLabel
.Left = 10
.Top = 10
.Width = 50
.Height = 25
.BorderStyle = BorderStyle.Fixed3D
.BackColor = Color.White
.ForeColor = Color.Blue
End With
End Sub
End Class
|
|
|
|
|
I don't see you putting any text on the label ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Anybloodyid wrote: Below is the code I have but nothing appears on the form?
Just add me.controls.add(MyLabel) after end with statement. It will show up on the form.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
Thanks June, it's always the obvious
|
|
|
|
|
you have to add the label to your form controls collection
try this in form load
form1.controls.add(mylabel)
A.E.K
|
|
|
|
|
Wondered if anybody can help me with this. I want to have a databound combobox and the first item will be "Add New Item". The combobox will otherwise be populated from a table. If the user needs to enter a new item they can click on "Add New Item" and add a new record to the bound table and when the user returns to the combobox the new item will be selected (something similar to QuickBooks comboboxes). Any ideas or help much appreciated.
|
|
|
|
|
I would suggest not binding to the combobox using the DataSource property as a solution. I'll give you a rough example, though I haven't tested it, I know it is possible.
Assuming the following:
A ComboBox named 'cboItems'
A Button named 'btnUpdate'
A TextBox named 'tbItemName'
A Typed-DataSet named 'dsData' of type ExampleDataSet
A Typed-DataTable in 'dsData' named 'ExampleItems' of type ExampleDataTable
A DataColumn in 'ExampleItems' named 'ItemName'
<code>
Public Sub Form_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load
'We will implement custom sorting, so disable the ComboBox automatic sorting
Me.cboItems.Sorted = False
Me.RefreshItems
End Sub
Private Sub RefreshItems
'Create a temp StringCollection to sort our data
Dim SortedItems As New Collections.StringCollection
For Each IRow as ExampleDataSet.ExampleRow In Me.dsData.ExampleItems
SortedItems.Add(IRow.ItemName)
Next
'Sort the list before adding it to the ComboBox
SortedItems.Sort
Me.cboItems.Clear
Me.cboItems.BeginUpdate 'Begin updating the combobox, recommended but not required all of the time
'Add the "Add New Item" first to ensure it is the first item
Me.cboItems.Items.Add("Add New Item")
For Each Name As String In SortedItems
Me.cboItems.Items.Add(Name)
Next
Me.cboItems.EndUpdate 'Finished updating the combobox
SortedItems = Nothing
'At this point, our ComboBox has at least one item "Add New Item" so we can safetly
'set the ComboBox.SelectedItem to 0
Me.cboItems.SelectedIndex = 0
'Alternative
'Me.cboItems.SelectedIndex = Me.cboItems.Items.IndexOf("Add New Item")
End Sub
Private Sub btnAdd_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnAdd.Click
Me.dsData.ExampleItems.AddExampleItemRow(Me.tbItemName.Text)
'After adding an item to the datasource, refresh the list to reflect the changes
'This can be done after deleting a row or updating it as well
Me.RefreshItems
End Sub
</code>
The previous example will work. However, I would suggest possibly using a button on the main form that opens a child form when clicked. The child form would have all of the controls needed to add the item. When the child form closed you could then add an item. This would allow you to bind directly to the combobox and not worry about all of the previous code.
Hope this helps,
If you have any other questions feel free to ask
Scott Page
"Some people spend an entire lifetime wondering if they made a difference. The Marines don't have that problem."
( President Ronald Reagan)
|
|
|
|
|
Thanks for all your help. I agree about that using a button may be a simpler option. I might actually use a context menu and let they user right click to bring up the form.
Thanks again
|
|
|
|
|
i have a clock alarm and want to send you
|
|
|
|
|
HoseinQuest wrote: ForumVisual Basic / VB.NET
Subject:Re: a Simple Clock Alarm
Sender:HoseinQuest
Date:15:43 6 Mar '07
i have a clock alarm and want to send you
If your aim is to submit your code, please use "Articles" and then select "submit an article". This is a forum.
What a curious mind needs to discover knowledge is noting else than a pin-hole.
|
|
|
|
|
Why don't the same datasources that show in the EXCEL data query screen show up in the add new database choice in vb.net? Do I need to add them to the project somehow?
Thanks!
|
|
|
|
|
How do I change the date or time field of the timedate control panel using the shell command (without displaying the applet). For example, I can change the timezone by specifying "control.exe timedate.cpl,,/Z" & StandardName where StandardName is the selected zone name. I would like to do the same thing for the date or time field. Is it possible?
Thanks for your help!
- Jewel
P.S: I am a new member so I am not so sure if i will be notified automatically via email (or how it works?) when someone replies to my message. So here is my email: minhchau.duong@triton.com
|
|
|
|
|
Maybe you can using the shell command to run "Date" or "Time" for specifying the date and time.... example "date 03-07-2007"
You must check "notify me by e-mail if someone answers this message"
so you will be automatically notify
|
|
|
|
|
Has anybody here had any experience writing code to work with a bar code scanner?
I’m just now starting to research this and I’m looking for resources.
My most basic requirement is to be able to generate a bar code that is associated with a specific folder in a directory structure. When that bar code is scanned, the folder will open up.
Thanks
Brad
|
|
|
|
|
Most barcode scanners just return text. It is just like someone typed keystrokes into the keyboard. So the only issue is what barcode type to use and does your barcode scanner support it. Certain barcode types only allow numbers, others allow both alpha and numeric. Some have check digits others don't.
If you need to create a barcode that your scanner can read, often this is as easy as finding the correct font and just displaying that font with the correct text.
So in your case, I would probably go with code 39 since it allows alpha characters. That way you could just create barcodes for your folder names. Then when the scan in your barcode you would have text that should be the folder name. At that point you could use that to open that folder. NOTE not all symbols are supported in some barcodes. So if you plan on needed to barcode certain symbols make sure the barcode you choose supports it.
Hope that helps.
Ben
|
|
|
|
|
Thanks. That gets me on the right track.
|
|
|
|
|
Hello ,
I am using thread in my vb.net program. This program works fine when I run it thru source code.
But when I build a setup and install it on a machine having .NET framework it does not execute the thread.
Thanks for any help in advance.
|
|
|
|