|
Christian Graus wrote: Break the task down into steps. Work it out on paper so your steps lead to the right answer. Step through in the debugger and work out at what point your code is not doing what you expect it to.
Excellent point.
Christian Graus wrote: suggest instead that you contact your teacher and tell them you are too dumb for their course.
Another excellent point
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
i got it to work on my own, didnt need ur help but thanks and God bless
hope that you dnt treat all users the way you
disrespected me.
|
|
|
|
|
Reformat your code so it is easier to read (use
code block tag) that aside, relook through the steps you are taking to solve the problem. You do have calculation mistakes and leaving it as an exercise for you to find.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
thanks i will do that next time i place code on the forums.
i got it to work anyways but thanks!
|
|
|
|
|
You are getting the incorrect result because you are trying to get the mean as a running total, and dividing only part of true mean, here is what i mean:
dFAvg = iSum / Convert.ToDouble(lblGrades.Text) 'calculate average
but the way you are calling it in the loop the first time you calculate the mean you are using only one number, then performing your deviation with that. The next loop you have the mean of 2 numbers and use that for your calculations. So what you want to do is load everything and calculate the mean, then use that to loop through and plug into your calculations. The below works:
Dim iSum As Integer = 0
Dim dFAvg As Double = 0
Dim dDev As Double = 0
Dim dSqDev As Double = 0
Dim strArr As Array = {1, 3, 4, 6, 9, 19}
For count = 0 To strArr.Length - 1
iSum += Convert.ToDouble(strArr(count))
lstGrades.Items.Add(strArr(count))
lblGrades.Text = lstGrades.Items.Count
lblSum.Text = iSum 'display sum in label box
dFAvg = iSum / Convert.ToDouble(lblGrades.Text) 'calculate average
Next
For count = 0 To strArr.Length - 1
dDev = ((strArr(count) - dFAvg) ^ 2)
dSqDev += dDev
Next 'end for
lblSumDev.Text = FormatNumber(dSqDev, 2)
End Sub
|
|
|
|
|
Hello,
Does anyone have a code example for vb.net 2008 to locate an email on a windows mobile device (checking the subject) and then read the body of it?
I can find examples in C but not VB. Any help would be great.
Thanks
|
|
|
|
|
|
Hello
I'm trying to do an auto uploader for my own usage, as I have a lot of files to upload.
I took a new form, put an hidden WebBrowser and made a "login" function. Okay, all of this is working nicely but I cannot find how to fill the form for uploading.
If you want the page : http://www.uploadjockey.com.
Can somebody please help me ?
Thanks in advance for your answers
|
|
|
|
|
hi there,
i asked a question earlier to try and get information from command prompt howver i seem to have found a better way.
here is the code used
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports System.Management
Namespace VBDotNet_WMI_HD_GetSerialNumber_2
Public Class MainForm
Inherits System.Windows.Forms.Form
Private button1 As System.Windows.Forms.Button
Public Shared Sub Main()
Dim fMainForm As New MainForm
fMainForm.ShowDialog()
End Sub
Public Sub New()
MyBase.New()
Me.InitializeComponent()
End Sub
#Region " Windows Forms Designer generated code "
Private Sub InitializeComponent()
Me.button1 = New System.Windows.Forms.Button
Me.SuspendLayout()
'
'button1
'
Me.button1.Location = New System.Drawing.Point(8, 8)
Me.button1.Name = "button1"
Me.button1.Size = New System.Drawing.Size(280, 32)
Me.button1.TabIndex = 0
Me.button1.Text = "&Get serial number"
AddHandler Me.button1.Click, AddressOf Me.Button1Click
'
'MainForm
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(292, 45)
Me.Controls.Add(Me.button1)
Me.Name = "MainForm"
Me.Text = "Testform <WMI - Harddisk - Get Serial Number. 2>"
Me.ResumeLayout(False)
End Sub
#End Region
Private Sub Button1Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
Dim Result As String = GetHarddiskSerialNumber("c:\")
If (Not Result Is String.Empty) Then
MessageBox.Show(Result, "Info")
End If
End Sub
Private Function GetHarddiskSerialNumber(ByVal drv As String) As String
Try
Dim BackSlash As String = "\"
Dim Position As Integer = drv.LastIndexOf(BackSlash)
If Position > -1 Then
drv = drv.Substring(0, drv.Length - 1)
Else
drv = drv
End If
Dim mo As New _
ManagementObject("Win32_LogicalDisk.DeviceID=""" & drv & """")
Dim pd As PropertyData = mo.Properties("VolumeSerialNumber")
Return pd.Value.ToString()
Catch ex As Exception
MessageBox.Show(ex.Message, "Info")
End Try
Return String.Empty
End Function
End Class
End Namespace
however this code is for vb6, and there are a few errors in it.
all i want the code for is to show a serial number up.
here is the link that may help
http://www.visual-basic5.de/vbclassic/dotnet/serialnumberfromhd.htm[^]
i don't really know much about WMI so that is why i am trying to pst as much info as i can
cheers
|
|
|
|
|
offroaderdan wrote: however this code is for vb6
i somehow don't think the code you listed is from vb6......do you mean that the code has been ported from vb6 original code and may contain some errors.
|
|
|
|
|
umm yeh it contains some errors.
|
|
|
|
|
and i ain't very good at solving them if im being perfectly honest.
I literally copied and pasted the code into a new form hoever when tryingto run the code this don't work
I really need this code so if anybody could help resolve this that would be great
|
|
|
|
|
Do you have the vb6 code?
|
|
|
|
|
no i thought it was orignally written in vb6 however it aint
i copied and pasted the code into vb.net however when trying to run it this doesn't work?
|
|
|
|
|
See my reply to your other post. There's a link to an example of executing a WMI query in there.
|
|
|
|
|
Thanks for the reply, this has now rely confused me. What would do i simply do something along the lines off
Dim instance As ManagementObjectSearcher
Dim returnValue As ManagementObjectCollection
returnValue = instance.Get()
and then something like
SELECT SerialNumber FROM Win32_BIOS"
??
i have never really tried anything like this before so its all new to me
|
|
|
|
|
i have tried using the code you said but got this far, how do i fix it?
Imports System
Imports System.Management
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Public Overloads Shared Function _
Main(ByVal args() As String) As Integer
End Function 'Main
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim s As New ManagementObjectSearcher( _
select SerialNumber from Win32_BIOS"" ' the bit of code you told me to put in it!!
New EnumerationOptions( _
Nothing, System.TimeSpan.MaxValue, 1, _
True, False, True, True, False, _
True, True))
For Each service As ManagementObject In s.Get()
'show the instance
TextBox1.Text = (service.ToString())
Next
End Sub
End Class
thanks Dave for the help!!
|
|
|
|
|
something like this
Public Sub q()
Dim s As New ManagementObjectSearcher( _
"root\MyApp", _
"SELECT SerialNumber FROM Win32_BIOS", _
New EnumerationOptions( _
Nothing, System.TimeSpan.MaxValue, 1, _
True, False, True, True, False, _
True, True))
For Each service As ManagementObject In s.Get()
'show the instance
TextBox1.Text = (service.ToString())
Next
End Sub
|
|
|
|
|
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
|
|
|
|