Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2008
Visual Studio
Visual Basic

  Switch on low bandwidth view
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
Visual Basic Guided Tour
What Went Wrong? Finding and Fixing Errors Through Debugging

When you write a computer program, errors can and will occur. You might make a typographical error, your program might not behave as expected, or it might not run at all. When there is an error in your program, you have to find it and fix it. Finding and fixing errors is called debugging.

In the following lessons, you will learn several techniques for debugging a Visual Basic program.

Finding the Errors: Introduction to Visual Basic Debugging

Describes how to debug a program and fix errors.

Know Your Bugs: Three Kinds of Programming Errors

Describes three kinds of errors that can occur in a program: compilation, run-time, and logic errors.

Finding and Getting Rid of Compiler Errors

Describes how to find and fix compiler errors in a program by using the Error List window and IntelliSense.

It Doesn't Work! Finding and Eliminating Run-Time Errors

Describes how to debug a program and fix run-time errors by using the Exception Assistant dialog box and IntelliSense.

What? It Wasn't Supposed To Do That! Finding Logic Errors

Describes how to find logic errors by setting breakpoints and stepping through code.

Making Notes in Your Programs: Using Comments

Describes how to create comments in the code for a program and how to use comments for debugging.

Closer Look: What If... Testing Code in the Immediate Window

Explains how to evaluate and run code by using the Immediate window.

Another Bug: Something Is Still Wrong

Explains how to find and fix a logic error that caused unexpected behavior.

Creating the Visual Look of Your Program: Introduction to Windows Forms

Explains how to use forms and controls to create a user interface.

Visual Basic Guided Tour

The Visual Basic Guided Tour is a series of sequential lessons that will introduce you to the basics of programming in Visual Basic.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
how to reset password through vbscript      Anirudhdelhi   |   Edit   |   Show History

username=inputbox("Enter username:")
if username = "" then wscript.Quit
strNewPassword = "Passw0rd"
ldapPath = FindUser(username)

if ldapPath = "Not Found" then
wscript.echo "User not found!"
Else
' Set password
'objUser.SetPassword strNewPassword
'objUser.SetInfo ' Save Changes
If Choice = username Then
' objUser.SetPassword (strNewPassword)
SetPassword = strNewPassword
' Display message if error changing password
If Err.Number <> 0 Then
Wscript.Echo "Unable to change password for user: " & _
objUser.sAMAccountName
Err.Clear
else
' Keep count of the number of password changes
intPasswordChanges = intPasswordChanges + 1
End If
end If
'End if

Function FindUser(Byval UserName)
on error resume next

set objRoot = getobject("LDAP://RootDSE")
domainName = objRoot.get("defaultNamingContext")
set cn = createobject("ADODB.Connection")
set cmd = createobject("ADODB.Command")
set rs = createobject("ADODB.Recordset")
'Set objUser = GetObject("LDAP://dc=india,dc=africa,dc=barclays,dc=org" & strUserDN)
cn.open "Provider=ADsDSOObject;"

cmd.activeconnection=cn
cmd.commandtext="SELECT ADsPath FROM 'LDAP://" & domainName & _
"' WHERE sAMAccountName = '" & UserName & "'"

set rs = cmd.execute

if err<>0 then
wscript.echo "Error connecting to Active Directory Database:" & err.description
wscript.quit
else
if not rs.BOF and not rs.EOF then
rs.MoveFirst
FindUser = rs(0)
else
FindUser = "Not Found"
end if
end if
cn.close
end function

' Display message
wscript.echo "Finished" & vbcrlf & intPasswordChanges & _
" Passwords changed"

Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker