Save info   Get password
Home Submit your blog Edit Account Rules RSS-Archive Contact


VB.Net Control Events Life Cycle
2008-01-22 10:13:00
Control Focus Events Cycle When you change the focus by using the keyboard (TAB, SHIFT+TAB, and so on), by calling the Select or SelectNextControl methods, or by setting the ContainerControl.ActiveControl property to the current form, focus events occur in the following order: 1. Enter 2. GotFocus 3. Leave 4. Validating 5. Validated 6. LostFocus Private Sub DataGridView1_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.Leave MsgBox("leave") End Sub Private Sub DataGridView1_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataGridView1.LostFocus MessageBox.Show("LostFocus") End Sub When you change the focus by using the mouse or by calling the Focus
Read more: Control

Manage Local Data Files in Projects
2008-01-22 10:09:00
A local database file can be included as a file in a project. The first time you connect your application to a local database file, you can choose between creating a copy of the database in your project or connecting to the existing database file in its current location. For more information, see Local Data Overview. If you choose to connect to the existing file, then a connection is created just as if you were connecting to any remote database, and the database file is left in its original location. If you choose to copy the database into your project, Visual Studio creates a copy of the database file, adds it to your project, and modifies the connection so that it now points to the database in your project. Existing data connections in Server Explorer are modi
Read more: Manage , Projects

What is a static class?
2008-01-22 10:08:00
What is a static class ? Static classes are classes that do not contain instance members other than those inherited from Object, and do not have a callable constructor. The members of a static class are accessed directly without an instance of the class. Example Console.WriteLine ("I Do not need any instances") Environment.CommandLine


Download Visual Studio 2008 and the .NET Framework 3.5
2007-12-27 20:16:00
Microsoft announced that Visual Studio 2008 and the .NET Framework 3.5 were released to manufacturing (RTM). With more than 250 new features,Visual Studio 2008 includes significant enhancements in every edition, including Visual Studio Express and Visual Studio Team System. Developers of all levels – from hobbyists to enterprise development teams – now have a consistent, secure and reliable solution for developing applications for the latest platforms: the Web, Windows Vista, Windows Server 2008, the 2007 Office system, and beyond. Learn more about Visual Studio 2008.MSDN Subscribers: Get Visual Studio 2008 NowDownload Trial Editions of Visual Studio 2008Download Visual Studio 2008 Express EditionsDownload the .NET Framework 3.5All of the above happening @ -us/vstudio/default.aspx


Visual Studio Add-ins vs. Shared Add-ins
2008-04-17 07:29:00
Types of Add-Ins in Visual StudioThere are two different Add-in project types: Visual Studio and Shared.A Visual Studio add-in can be loaded into both Visual Studio and the Visual Studio Macros IDE. Conversely, a Shared add-in can be loaded only into Microsoft Office applications such as Microsoft Word, Microsoft Publisher, Microsoft Visio, and Microsoft Excel. Also, each type offers a different set of options.For example, the Visual Studio Add-in Wizard allows you to:• Create a command bar user interface (UI) for your add-in,• Define when the add-in loads, and• Insert information into the Visual Studio Help About box.The Shared Add-in Wizard only allows you to:• Specify whether the add-in loads when the host application (that is, the Office application) loads, and• Specify wheth


Check Type of Variable in VB.Net
2008-04-27 10:37:00
Identify Variable Type in VB.NET Sub Check _Variable_Types() Dim varByte As SByte Dim varInt As Integer Dim varString As String Dim varExp As Exception varString = "Temp" varExp = New System.Exception("Sample Exception") Dim varArr As Object() = {varByte, varInt, varString, varExp} 'The Object data type can point to data of any data type, including any object instance your application recognizes. Use Object when you do not know at compile time what data type the variable might point to. 'The default value of Object is Nothing (a null reference). MsgBox(varArr.GetType.ToString()) For Each obj As Object In varArr MsgBox(obj.GetType.IsValueType) 'Gets a value indica


Nullable Type in Visual Basic.Net
2008-04-27 10:33:00
Storing Null Values in VB.Net VariablesMost of times we use variables to store the response from the user; might be a simple message box. In that case, we would be using a boolean variable - one that can store True or False. What if the User didn't answer the question? It would be taken as False by default. To overcome this you can use the variable as Nullable. Now the var can have three states - True , False and Null Sub Nullable_Example() ' Nullable type will be used to check if the value is assigned Dim Answer As Nullable(Of Boolean) Dim RetVal ' As MsgBoxResult RetVal = MsgBox("Have you booked the ticket for olympics", vbYesNoCancel, "DotNetDud Examples") If RetVal = vbYes Then Answer = True ElseIf RetVal = vbN
Read more: Visual , Basic , Visual Basic

Using Timer in VB.Net
2008-04-27 10:29:00
Building an Electronic Clock in VB.Net using timer class(VB.NET ProgressBar using Timer ) Public Class Form1 Dim t As New Timer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load t.Interval = 1000 AddHandler t.Tick, AddressOf Me.t_ShowProgress AddHandler t.Tick, AddressOf Me.t_ShowTime t.Start() End Sub Private Sub t_ShowProgress() ProgressBar1.Value += 10 If ProgressBar1.Value = 100 Then ProgressBar1.Value = 0 End If End Sub Private Sub t_ShowTime() Label1.Text = Now End Sub End Class Add Handler - Associates an event with an event handler at run time. The Handles keyword and the AddHandler statement both all


Regular Expressions in Dot Net (.NET)
2008-04-27 09:04:00
Finding Duplicate Words in a String using .NET Regular Expressions Regular Expressions (REGEX) does wonders in programming. Here is a simple Regex code that identifies duplicate words like 'the the', 'something something' etc. Probably copyeditors can use this code to do the work that Microsoft Spell check does Sub Regex_Checker_Duplicate_Words() Dim oRegex As Regex Dim sPattern As String Dim oMatches As Match Dim sText As String sText = " the the category catastropic cat cat and rat b b " sPattern = "\b([a-zA-Z]+)\s+\1" oRegex = New Regex(sPattern) oMatches = oRegex.Match(sText, sPattern) While oMatches.Success MsgBox(oMatches.Groups(0).Value.ToString) oMatches = oMatches.Ne


Function '' doesn't return a value on all code paths
2008-04-27 09:02:00
Function '' doesn't return a value on all code paths The error Function '' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used occurs when a Function procedure has at least one possible path through its code that does not return a value. You can return a value from a Function procedure in any of the following ways: · Assign the value to the Function procedure name and then perform an Exit Function statement. · Assign the value to the Function procedure name and then perform the End Function statement. · Include the value in a Return Statement (Visual Basic). If control passes to Exit Function or End Function and you have not assigned


Access of shared member through an instance; qualifying expression will not be evaluated
2008-04-27 09:01:00
Access of shared member through an instance; qualifying expression will not be evaluated This error occurs when an instance variable of a class or structure is used to access a Shared variable, property, procedure, or event defined in that class or structure. This warning can also occur if an instance variable is used to access an implicitly shared member of a class or structure, such as a constant or enumeration, or a nested class or structure. · Use the name of the class or structure that defines the Shared member to access it. · Ensure that two variables do not have the same name in a particular scope The purpose of sharing a member is to create only a single copy of th
Read more: Access

Late bound resolution in .NET
2008-04-27 08:59:00
Late bound resolution; runtime errors could occur This error (Error ID: BC42017) occurs because an object is assigned to a variable declared to be of the Object Data Type. When you declare a variable as Object, the compiler must perform late binding, which causes extra operations at run time. It also exposes your application to potential run-time errors. For example, if you assign a Form to the Object variable and then try to access the XmlDocument..::.NameTable property, the runtime throws a MemberAccessException because the Form class does not expose a NameTable property. If you declare the variable to be of a specific type, the compiler can perform early binding at compile time. This results in improved performance, controlled access to the members of the specific type, and better


Implicit conversion from '' to ''
2008-04-27 08:57:00
An expression or an assignment statement takes a value of one data type and converts it to another type. Because no conversion keyword is used, the conversion is implicit. Implicit conversion from 'Object' to 'Microsoft.Office.Core.CommandBars' can be rectified using CType(app.CommandBars, Microsoft.Office.Core.CommandBars) Ctype returns the result of explicitly converting an expression to a specified data type, object, structure, class, or interface. expression Any valid expression. If the value of expression is outside the range allowed by typename, Visual Basic throws an exception. typename Any expression that is legal within an As clause in a Dim statement, that is, the name of any data type, object, structure, class, or interface. CType is compil


Use of aliases in .NET (Imports Statement)
2008-04-27 08:55:00
Imports Statement (.NET Namespace and Type) – Use of aliases Use of aliases can save your precious time. Imports Microsoft.Office.Interop.Excel Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim oXL As Microsoft.Office.Interop.Excel.Application oXL = New Microsoft.Office.Interop.Excel.Application can be changed to Imports Excel = Microsoft.Office.Interop.Excel Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim oXL As Excel.Application oXL = New Excel.Application Saves a lot of typing and more concise. Import aliases are us


Change the default values of Option Explicit and Option Strict in .NET
2008-04-27 08:51:00
Change the Default Project Values in .NET You can change the default values of Option Explicit and Option Strict on a per project type basis. For example, when you create a new Visual Basic .NET or Visual Basic 2005 application, the value for Option Explicit is set to On. You can change this default value to Off.To change the default values of Option Explicit and Option Strict, follow these steps: Locate the following project template files on your system: EmptyProjectIPF.vbproj EmptyWebProjectIPF.vbproj WebApplication.vbproj WebControl.vbproj WebService.vbproj WindowsApplication.vbproj WindowsControl.vbproj WindowsService.vbproj Open a project template in Notepad. Add (or edit if they are already present) the OptionStrict
Read more: Change

Conversions in Dot Net (.Net) - Strict , Widening and Narrowing
2008-04-27 08:46:00
Impact of Option Strict in Conversions (.NET) Option Strict restricts implicit data type conversions to only widening conversions. Widening conversions explicitly do not permit any data type conversions in which data loss may occur and any conversion between numeric types and strings. For more information about widening conversions, see the Widening Conversions section.When you use the Option Strict statement, the statement must appear before any other code. In Visual Basic .NET, you can typically convert any data type to any other data type implicitly. Data loss can occur when the value of one data type is converted to a data type with less precision or with a smaller capacity. However, you receive a run-time error message if data will be lost in such a conversion. Option Strict notifies


Using Vb.Net Function in VBA
2008-04-27 08:26:00
How to use a VB.Net DLL/TLB in Excel VBAHere is an example for using the customized .NET Function in Excel VBA. Unfortunately EXcel VBA doesn't have a Array.Sort function. To overcome the shortcomings, we create our own function here in .Net and use the same in Excel VBAHere are the steps:Create a class library project in Visual StudioAdd a COM Class item (DND_SortArray in this example)In the assembly information edit the title, company and provide a meaningful description. This would be seen in the References dialog in ExcelAdd the code shown below: _ Public Class DotNetDud_SortArray #Region "COM GUIDs" ' These GUIDs provide the COM identity for this class ' and its COM interfaces. If you change them, existing ' clients will no longer be able to access the class.


Extract Interface from Custom Class (C#)
2008-04-27 08:24:00
How to Extract Class Members to Interface in C# You can extract one or more public members from a type into a new interface. To extract members to a new interface 1. In Class Designer, right-click the type that contains the member or members you want to extract, point to Refactor, and click Extract Interface. The Extract Interface dialog box displays default values for the name of the interface and the name of the code file in which it will be declared. Either accept the default values or change them. 2. In the Select public members to form interface pane, select or clear the check box next to the members you want to extract into the new interface, and click OK. A new interface is created, and the file that houses it is added to the project.


Get Free Disk Space in all drives using VB.Net
2008-04-30 08:41:00
Get Available Disk Space using VB.Net Sub GetSpaceInDrives() 'Dim oDinfo As DriveInfo Dim oDrvs() As DriveInfo = DriveInfo.GetDrives For Each Drv In oDrvs If Drv.IsReady Then MsgBox(Drv.Name & " " & Drv.AvailableFreeSpace.ToString) End If Next End Sub The statement Dim oDrvs() As DriveInfo = DriveInfo.GetDrives retrieves the drive names of all logical drives on a computer. The IsReady property returns true if the drive is ready; false if the drive is not ready. If this check is not done then you will get System.IO.IOException was unhandled Message="The device is not ready. " exception. AvailableFreeSpace property indicates the amount of free space available on t


Copying Files using .Net Functions
2008-04-30 08:39:00
CopyFile Function in VB.Net Imports System.IO Function CopyFile(ByVal sSourceFile As String, ByVal sDestnFile As String) Dim oFile As New FileInfo(sSourceFile) If oFile.Exists Then oFile.CopyTo(sDestnFile) Else MsgBox("File Does not exist") End If End Function Use the FileInfo class for typical operations such as copying, moving, renaming, creating, opening, deleting, and appending to files. Many of the FileInfo methods return other I/O types when you create or open files. You can use these other types to further manipulate a file. For more information, see specific FileInfo members such as Open, OpenRead, OpenText, CreateText, or Create. If you are going to reuse an object several times, co
Read more: Copying , Functions

Send emails asynchronously using .NET
2008-05-06 04:44:00
Send Asynchronous emails using VB.NET Imports System.Net.Mail Imports System.Net.Mime Imports System.ComponentModel Sub Send_Email_Asynchronously() Try Dim oMailMsg As MailMessage Dim oClient As SmtpClient oMailMsg = New MailMessage oMailMsg.From = New MailAddress("admin@vbadud.com") oMailMsg.To.Add(New MailAddress("sample@yahoo.co.au")) oClient = New SmtpClient("smtp.vbadud.com") ' configure client AddHandler oClient.SendCompleted, AddressOf Client_SendCompleted ' Send message oClient.EnableSsl = True ' Send Message Asynchronously oClient.SendAsync(oMailMsg, Nothing) Catch ex2 As SmtpFailed


Create HTML Message with Embedded Images in VB.NET / Embed images in HTML mail message using VB.NET
2008-05-06 04:41:00
Send mails in both HTML and Text Format using VB.NET / Automatically direct messages in HTML / Text format using .NET Imports System.Net.Mail Imports System.Net.Mime Imports System.ComponentModel Sub Create_HTML_Mail_With_Embedded_Images() Dim oMailMsg As MailMessage Dim oSMtPClient As SmtpClient Dim sTEXTBody As String Dim avTEXTBody As AlternateView Dim sHTMLBody As String Dim avHTMLBody As AlternateView oMailMsg = New MailMessage oMailMsg.From = New MailAddress("sample@dotnetdud.com", "Dot Net Dud Sample") ' If you do not use the constructor and add address using To.Add you can add more addresses oMailMsg.To.Add(New MailAddress("subscriber@dotnetdud.com", "Feed Subsc


Send HTML Messages using .NET
2008-05-06 04:35:00
Send HTML Messages using .NET Create and Send HTML mails using VB.NET Use the IsBodyHtml property to specify whether the body of the e-mail message contains plain text or HTML markup Imports System.Net.Mail Sub Create_HTML_Mail() Dim oMailMsg As MailMessage Dim oSMtPClient As SmtpClient oMailMsg = New MailMessage oMailMsg.From = New MailAddress("sample@dotnetdud.com", "Dot Net Dud Sample") ' If you do not use the constructor and add address using To.Add you can add more addresses oMailMsg.To.Add(New MailAddress("subscriber@dotnetdud.com", "Feed Subscribers")) oMailMsg.To.Add(New MailAddress("techwriters@dotnetdud.com", "Tech Writers")) oMailMsg.Subject = "Welcome to Mailing List" oMai


Validate eMail Addresses using VB.NET Function
2008-05-06 04:34:00
Detect errors in email addresses using .NET exception handling There are n-number of ways to detect errors in email addresses; some use regular expressions to do that. The same has been built as a check in ASP.NET validation controls. The following function uses the Try-Catch exception handling by assigning the address to the mail message. If the format of the email address is found to be wrong, then the function returns false. A simple one; please post your comments on the way it worksJ Function Detect_MailAddress_Errors(ByVal sMailAdd As String) As Boolean Try Dim oMailMsg As New MailMessage oMailMsg.To.Add(sMailAdd) Return True 'Format Exceptions Catch exFormat As FormatException 'MsgBox("F
Read more: Validate

Create Mail in Vb.Net with attachments
2008-05-06 04:33:00
Automatically send a mail with attachment using VB.NET Imports System.Net.Mail Imports System.Net.Mime Imports System.ComponentModel Sub CreateMail_With_Attachment() Dim oMailMsg As New MailMessage Dim oMailClient As SmtpClient oMailMsg.From = New MailAddress("info@vbadud.com") oMailMsg.To.Add(New MailAddress("admin@vbadud.com", "Administrator")) oMailMsg.Body = "Attached Sample Document for processing." oMailMsg.Subject = "Sample Mail" oMailMsg.Attachments.Add(New Attachment("C:\temp\sample.doc")) oMailClient = New SmtpClient("smtp.vbadud.com") oMailClient.Send(oMailMsg) End Sub The Attachment class is used with the MailMessage class. All messages include a Body, which contains


Creating and Sorting an ArrayList
2008-05-06 04:30:00
Example of System.Collections namespace in ArrayList The System.Collections namespace contains interfaces and classes that define various collections of objects, such as lists, queues, bit arrays, hash tables and dictionaries. Arraylist is one of the basic collection; it implements the IList interface using an array whose size is dynamically increased as required Imports System.Collections Sub Main() Dim aList As New ArrayList Dim arStr() As String = {"Apple", "Aaron", "Byron", "Reddy"} aList.AddRange(arStr) For Each aLis As String In aList Console.WriteLine(aLis) Next Console.WriteLine() ‘Sort Array aList.Sort() For Each aLis As String In aList Console.WriteLine(aL
Read more: Creating , Sorting

.NET 3.5 Enhancements Training Kit
2008-05-07 01:06:00
OverviewThe .NET Framework 3.5 Enhancements Training Kit includes presentations, hands-on labs, and demos. This content is designed to help you learn how to utilize the .NET 3.5 Enhancement features including: ASP.NET MVC, ASP.NET Dynamic Data, ASP.NET AJAX History, ASP.NET Silverlight controls, ADO.NET Data Services and ADO.NET Entity Framework.System RequirementsSupported Operating Systems: Windows Vista; Windows XPMicrosoft Windows VistaMicrosoft Visual Studio 2008Microsoft SQL Server 2005 (Express recommended)Microsoft Office Powerpoint 2007 or the PowerPoint Viewer 2007 - Required to view the presentationsWindows PowerShell 1.0 RTMInstructionsDownload and execute the kit. The kit will uncompress to the selected folder and launch a HTML browser for the content.Download @


Extract Ref Links From WebPage using VB.Net Regular Expressions
2008-06-01 02:49:00
Extract Links From WebPage using VB.Net Regular Expressions Sub Extract_Links_From_WebPage() Dim oReg As Regex Dim oMat As Match Dim sInputString As String Dim sLink As String sInputString = "some have links that direct to some html files " oReg = New Regex("href\s*=\s*(?:""(?[^""]*)|(?\S+))", RegexOptions.Compiled Or RegexOp


Remove HTML Tags from String using .NET Regular Expressions
2008-06-01 02:48:00
Strip HTML Tags from String using Regular Expressions Sub Regex_Replace_Example() Dim oReg As Regex Dim sInput As String Dim sOut As String ' Strip of Simple HTML Tags sInput = "This is a HTML Text" oReg = New Regex("") sOut = oReg.Replace(sInput, "", "") ' Strip of Complex HTML Tags sInput =


VB.NET Regular Expression to Check URL
2008-06-01 02:47:00
VB.NET Regular Expression to Validate UrlImports System.Text.RegularExpressions Function IsValid_URL_Address(ByVal sURLAdd As String) Return Regex.IsMatch(sURLAdd, "(https?|ftp):\/\/([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})(:\d{1,4})?([-\w\/#~:.?+=&%@~]*)/") End Function The above will check for URL like etc
Read more: Check

Page 1 of 2 « < 1 2 > »
eXTReMe Tracker