okey progressBar. det så dejlig nemt til at starte med. og jeg har prøvet at erlære progresbar as progressbar.
se min kode:
Imports System.IO
Imports System
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim objConnection, objCommand, objRecordSet
Dim Pbar1 As ProgressBar
Dim sw As StreamWriter = New StreamWriter("c:\testfile.txt")
Dim sw1 As StreamWriter = New StreamWriter("c:\testfile1.txt")
Dim taeller As Integer
sw.Flush()
sw1.Flush()
objConnection = CreateObject("ADODB.Connection")
objCommand = CreateObject("ADODB.Command")
objConnection.Provider = "ADsDSOObject"
objConnection.Open("Active Directory Provider")
objCommand.ActiveConnection = objConnection
objCommand.CommandText = _
"Select Name, Location from '
LDAP://ou=pc,ou=Boligerne Gefion,ou=Boligerne Gefion,ou=Social og Psykiatri,ou=Frederiksborg,DC=fa,DC=root,dc=local' " _
& "Where objectClass='computer'"
objRecordSet = objCommand.Execute
objRecordSet.MoveFirst()
taeller = 0
Do Until objRecordSet.EOF
sw.WriteLine(objRecordSet.Fields("Name").Value)
objRecordSet.MoveNext()
taeller = taeller + 1
Loop
sw.Close()
' Display the ProgressBar control.
Pbar1.Visible = True
' Set Minimum to 1 to represent the first file being copied.
Pbar1.Minimum = 1
' Set Maximum to the total number of files to copy.
Pbar1.Maximum = taeller
' Set the initial value of the ProgressBar.
Pbar1.Value = 1
' Set the Step property to a value of 1 to represent each file being copied.
Pbar1.Step = 1
Dim sr As StreamReader = New StreamReader("c:\testfile.txt")
Dim StrComputer As String = sr.ReadLine()
Do While Not StrComputer Is Nothing
Try
If My.Computer.Network.Ping(StrComputer, 20) Then
sw1.WriteLine(StrComputer)
End If
Catch
End Try
StrComputer = sr.ReadLine()
' Perform the increment on the ProgressBar.
Pbar1.PerformStep()
Loop
sw1.Close()
sr.Close()
End Sub
Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
End Sub
End Class
Men når man kører programmet så kommer den med denne fejl: Object reference not set to an instance of an object.
er det fordi jeg mangler at erklære nogle variabler?
Visual Basic (Declaration)
<ComVisibleAttribute(True)> _
<ClassInterfaceAttribute(ClassInterfaceType.AutoDispatch)> _
Public Class ProgressBar
Inherits Control
har det noget med det her at gøre?