|
Here,
Create a new winforms project;
Add a reference to System.Management
Add 2 List boxes to your form and a button with name to match the code below and Run it.
Imports System.Management
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
'Enumarate Drives List
For Each drive As System.IO.DriveInfo In System.IO.DriveInfo.GetDrives
ListBox1.Items.Add(drive.Name)
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If ListBox1.SelectedItems.Count > 0 Then
ListBox2.Items.Clear()
'Get the WMI Properties for the Drive and populate the list box
Dim query As New SelectQuery("Win32_LogicalDisk")
'ManagementObjectSearcher retrieves a collection of WMI objects based on the query.
Dim search As New ManagementObjectSearcher(query)
' Display each entry for Win32_LogicalDisk
Dim info As ManagementObject
For Each info In search.Get()
For Each item As PropertyData In info.Properties
ListBox2.Items.Add(item.Name & " : " & item.Value)
Next
Next
End If
End Sub
End Class
modified on Wednesday, October 28, 2009 1:10 PM
|
|
|
|
|
works like a treat!
However is there any way that i can get drive "C" to appear and in a textbox and have volume serial number of the drive in a txtbox.
so it would look something like this
text box 1 contents = volume serial "blah blah blah"( number) of "C"
I have never really played around with list boxes, i only really know txt boxes and labels!!
Many thanks Dave!
|
|
|
|
|
Thats just basic string manipulation. If you can't work that out you shouldn't be trying to mess about with WMI!
Also if you look at the documentation for the classes used, you will see it is also possible to query just the single property you want, rather than have to iterate each one.
Go try and figure it out, and then come back with what you tried if you have problems.
I am not going to do it all for you!
|
|
|
|
|
ok i had ago with the changing the code around
this is how far i got t cant seem to figure it out all i need is if drive "c" contains a volume serial number then that is placed on a text box
i had a go at changing
For Each drive As System.IO.DriveInfo In System.IO.DriveInfo.GetDrives
ListBox1.Items.Add(drive.Name)
Next
to Dim drive as system.io.driveInfo
listbox1.items.add("C:/")
this seemed to work however in list box 2 it still displayed 4 drives??
i tried to extract certain bits of data from lit box to textbox, however this didn't work.
If ListBox2.Items.Contains("VolumeSerialNumber" & " : " & item.value) Then
TextBox1.Text = "VolumeSerialNumber" & " : " & item.value
End If
Is there any way that with each drive a list box can be dedicated to that drive rather than having a massive list?
Many thanks
|
|
|
|
|
|
definitly not ... imports ... not in vb6
|
|
|
|
|
Hello Everybody
I have create an outlook plug-in which is use to send the new mail from inbox to other user. when i send mail from my company mail account to outlook then outlook again send the mail to particular user then it is adding HYPERLINK mailto:dc@isol.co.in automatically. i only want to send original message and don't want to add extra word.
Let me explain with example:
I send mail from my company E-mail ID and mail body contains following information "Send all query at dc@isol.co.in"
When i click on outlook send/receive button i received same message as above.
but using plug-in when i forward this outlook mail to other user then he is getting following message
"Send all query at HYPERLINK mailto:dc@isol.co.in dc@isol.co.in"
in above message HYPERLINK mailto:dc@isol.co.in is extra word. i want to remove this.
how can i handle this, please give me advice.
I am using vb.net 2005 and outlook 2007
Thanks
Dharmchand Dhingra
|
|
|
|
|
Hi there,
Is there any way that i can use command prompt to get info that is needed for my program,
I am currently doing a project on security and we have got to "try" and make a program that will make it harder for another person to use the program.
I have found out that using command prompt and typing in "wmic bios get serialnumber"
this then displays a serial number
i would like to incorporate this number displayed in the command prompt into the program as this will be saved on a .txt file
any ideas would be very helpful
i am a bit of a noob programmer so sorry if being a bit thick
i am using vb.net
cheers
|
|
|
|
|
That is just a WMI query returning the manufacturer supplied serial number from an instance of the WMI "Win32_BIOS" class, from the WMI Namespace "root\CIMV2".
The WQL string would look like this:
SELECT SerialNumber FROM Win32_BIOS"
You can find an example of returning an object from WMI here[^].
Please keep in mind that there is nothing that says each manufacturer has to supply that information in WMI. You might get nothing back.
modified on Wednesday, October 28, 2009 10:27 AM
|
|
|
|
|
I am allowing a user to input values into a text box click a button and then display and calculate the standard deviation of the values enterd, but the code i came up with does not seem to be working correctly, and i cant figure out why or what is wrong????? I need to get each value entered by the user, then subtract each value by the Mean/avg and store the answer in a variable(dDev), then i need to sqaure each value, after that then i need to add each value i have come up with and then add the squared values together for a TOTAL
Str = txtGrades.Text 'store string into variable
strArr = str.Split(" ") 'use split to seperate words by space
For count = 0 To strArr.Length - 1
'add user entered values to list box
lstGrades.Items.Add(strArr(count))
lblGrades.Text = lstGrades.Items.Count
iSum += Convert.ToDouble(strArr(count)) 'get sum of values entered and pass to storing variable
lblSum.Text = iSum 'display sum in label box
*********************************************************************
dDev = ((strArr(count) - (dFAvg)) ^ 2)
dSqDev += dDev
*********************************************************************
dTotalDev = (dSqDev / strArr.Length - 1)
Next 'end for
dFAvg = Convert.ToDouble(lblSum.Text) / Convert.ToDouble(lblGrades.Text) 'calculate average
lblAvg.Text = FormatNumber(dFAvg, 2) 'display average after storing calculation in variable, format to display only 2 decimal places
lblSumDev.Text = FormatNumber(dSqDev, 2)
|
|
|
|
|
You appear to me to be a little dense. The last time you asked this, it was pointed out that iSum is never initialised. I still don't see code to do that, and that would certainly break your result.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Dim iSum As Integer = 0
Dim dFAvg As Double = 0
Dim dDev As Double = 0
Dim dSqDev As Double = 0
i have these being declared before my subroutine
then this is my subroutine for my array using a for loop to load all values into teh list
but the part that dont know if i am dng correctly is my dDev= ((strArr(count) - dFavg) ^2) it keeps giving me the wrong answer
For count = 0 To strArr.Length - 1
'add user entered values to list box
lstGrades.Items.Add(strArr(count))
lblGrades.Text = lstGrades.Items.Count
iSum += Convert.ToDouble(strArr(count)) 'get sum of values entered and pass to storing variable
lblSum.Text = iSum 'display sum in label box
'***********************
dFAvg = iSum / Convert.ToDouble(lblGrades.Text) 'calculate average
'***********************
dDev = ((strArr(count) - dFAvg) ^ 2)
dSqDev += dDev
Next 'end for
|
|
|
|
|
PAguilar09 wrote: i have these being declared before my subroutine
This means your code will only work once.
PAguilar09 wrote: iSum += Convert.ToDouble(strArr(count))
iSum is an integer, why are you converting to double ?
PAguilar09 wrote: dFAvg = iSum / Convert.ToDouble(lblGrades.Text)
How does this calculate an average when it's done on each iteration ? Why not just use lstGrades.Items.Count instead of converting the string ?
Either way, it seems wrong to me. Each time around, the total so far gets divided by the total number of items ( not the number of items added so far ). Then you take this value, which is not an average of anything, and you subtract it from the last added value. Then you square that number. Then you add this to the cumulative total. I don't understand how that gives you any sort of meaningful result.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
So when you say that my code will only work once, then Do i need to declare in the subroutine my variables = 0??
I am converting the strArray(count) to Double because it is declared as a STRING when i create the variable. I dont know if it is the correct way to be doing it
on the last code you explained about, what it is doing is dividing the sum that has been passed to the Variable(iSum, a INTEGER)
then divide that by the total number of grades the user has entered, i convert it to double because since its a label.text it is a STRING not a numeric value.
Here is my total code maybe someone can tell me what it is i am dng wrong?? I have everything working fine BUT THE dDev = ((strArr(count)- dFAvg) ^2)
and then take that value being stored into dDev for each item from the listbox and find teh sum again.
Public Class GradeForm
Dim str As String
Dim strArr() As String
Dim count As Integer
Dim iSum As Integer = 0
Dim dFAvg As Double = 0
Dim dDev As Double = 0
Dim dSqDev As Double = 0
Dim dTotalDev As Double
Dim STD As Double
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
'*************************************************************************************
'in this subroutine the User will click the save button to save grades to an array and
'then display the data required by the program.
'*************************************************************************************
Str = txtGrades.Text 'store string into variable
strArr = str.Split(" ") 'use split to seperate words by space
For count = 0 To strArr.Length - 1
'add user entered values to list box
lstGrades.Items.Add(strArr(count))
lblGrades.Text = lstGrades.Items.Count
iSum += Convert.ToDouble(strArr(count)) 'get sum of values entered and pass to storing variable
lblSum.Text = iSum 'display sum in label box
'***********************
dFAvg = iSum / Convert.ToDouble(lblGrades.Text) 'calculate average
'***********************
'********************THIS IS WHAT IS NOT WORKING CORRECTLY IT SEEMS THAT IT ISN'T GETTING EACH ELEMENT OR ITEM FROM TEH LIST BOX AND HAVE IT SUBRTRACTED BY THE AVG/MEAN, THEN RAISE IT OR MULTIPLY IT BY ITSELF (^2)***************************D
dDev = ((strArr(count) - dFAvg) ^ 2)
dSqDev += dDev
Next 'end for
lblAvg.Text = FormatNumber(dFAvg, 2) 'display average after storing calculation in variable, format to display only 2 decimal places
'this IS STILL NOT WORKING!!!!!*************************
lblSumDev.Text = FormatNumber(dDev, 2)
''''''''''''''''''''''this part is correct
STD = (lblSumDev.Text / (strArr.Length - 1))
Dim final As Double = Math.Round(Math.Sqrt(STD), 2)
lblStdDev.Text = final
End Sub
|
|
|
|
|
How to make multiline textbox to display the last element added or scroll to last?
|
|
|
|
|
you can scroll to the bottom. If you type the name of the textbox and hit the ., intellisense will let you see all the methods on the control, and you can also read MSDN to read up on the methods on a class.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
use ScrollToEnd() or ScrollToCaret()
bless
|
|
|
|
|
I Am using VB6 it doesnt have scroll to end
|
|
|
|
|
Hi,
I am using using AVICAP32 for recording and saving Video.But when the form is minimized the Video is not saved also the Size of File for AVI files is very large when saved.What is the Problem and how it can be solved.
Is there any free dll which can be used in the Application.
|
|
|
|
|
kjsl2k9 wrote: also the Size of File for AVI files is very large when saved
avi files are not compressed, therefore they are large. I don't know what avicap32 is, but for the files to be smaller, you'd need to have some sort of codec installed, and to use it in your capture.
kjsl2k9 wrote: .But when the form is minimized the Video is not saved
This is somewhat meaningless. You don't even tell us what video you're capturing, I don't see how we can help based on this.
kjsl2k9 wrote: Is there any free dll which can be used in the Application.
Ultimately, you can do video capture using DirectX, and there are plenty of C# DX wrappers.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi Everyone,
Can some one tell me how to create a VB.NET based application that could be used in a local server through which all the PCs are connected?
e.g. if I want to build a "Employee Record Management System" using VB and SQL Server 2005 database, and want users to work on this software installed on multiple PCs and simultaneously updating the database, then How to go ahaead with this?
I think, the software will be installed in all the PCS and SQL server Database will be on any separate PC which will act as server. I am not sure how to go ahead with this.
Any tutorials/links/refernces will be appriciated.
Thanks
RS.
|
|
|
|
|
Google Client Server development using VB.NET.
You really need to have some basic understanding of development concepts - if you have not done any sort of formal training, I recommend you get hold of a VB.NET book and learn the basics first!
|
|
|
|
|
I have done only windows based application with SQL sever 2005. Now I am moving to client-server based application.
|
|
|
|
|
Then buy a book on ASP.NET assuming that's how you write it.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
I am currently allowing a user to enter in values into a text box. Then click a button to display the values and find the sum and mean of all the values entered. But i saw a problem when i was testing out the program.
When the user 1st runs the program it works perfecT! but if the user tries to re-enter new values and click the display button again, the sum and mean is added to the previous mean and sum so the values are way off!!! Here is my code I am not sure what I am forgetting to do? I know its something DEALING WITH MY FOR LOOP and COUNTER
Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
'*************************************************************************************
'in this subroutine the User will click the save button to save grades to an array and
'then display the data required by the program.
'*************************************************************************************
Str = txtGrades.Text 'store string into variable
strArr = str.Split(" ") 'use split to seperate words by space
For count = 0 To strArr.Length - 1
'add user entered values to list box
lstGrades.Items.Add(strArr(count))
lblGrades.Text = lstGrades.Items.Count
iSum += Convert.ToDouble(strArr(count)) 'get sum of values entered and pass to storing variable
lblSum.Text = iSum 'display sum in label box
Next 'end for
dFAvg = Convert.ToDouble(lblSum.Text) / Convert.ToDouble(lblGrades.Text) 'calculate average
lblAvg.Text = FormatNumber(dFAvg, 2) 'display average after storing calculation in variable, format to display only 2 decimal places
lblStdDev.Text = STD
End Sub
'this is the subroutine for my clear text box
Private Sub btnClear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnClear.Click
'********************************************************************8
'this subroutine will simply clear out the text box containing the user entered data
'as well as the lstbox displaying all the values entered
'and allow him/her to enter in new data
txtGrades.Text = ""
lblGrades.Text = ""
lblSum.Text = ""
lblAvg.Text = ""
lstGrades.Items.Clear()
txtGrades.Focus()
End Sub
|
|
|
|