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


StackTrace in Visual Basic .Net
2007-07-13 21:51:00
StackTrace in VB.Net Stack Trace is a string that describes the contents of the call stack, with the most recent method call appearing first. This is most commontly used to know the place of code that generated an exception Sub Stack_Trace_Exception_Example() Try Dim iVar As Long iVar = "Assign String" Catch ex As Exception MsgBox(ex.StackTrace) End Try End Sub The above example shows the stacktrace in message box when the type mismatch exception is thrown The execution stack keeps track of all the methods that are in execution at a given instant. A trace of the method calls is called a stack trace. The stack trace listing provides a means to follow the call sequence to the line number in the method where the exception occurs. StackTrace may not report as many method calls as expected, due to code transformations, such as inlining, that occur during optimization. The StackTrace property is overridden in classes that req
Read more: Basic , Visual , Visual Basic

Opening & Closing Notepad using .Net
2007-06-30 02:22:00
Opening & Closing of Application using .Net / Create New process in .Net / Shell Function in .NetA program is not Userinterface and database connections alone, it also needs to interact with other applications. Many a times, this interaction happens internally, like updating Word Template, Printing out a document etc, but there are times where one needs to open an document through the Application.Let us have a sample app that opens a Notepad on click of a command button. We have a sample form with a button (see below).Now add the process control from the Components Control (see below)This control has no design features and will be used in run-time and it straightway gets docked in the tray (see below)Change the following properties of the control.This can also be changed during run time.Now in the Button Click event write the following code:Private Sub ButtonNotepad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles loadNotepadButton.Click ' http://dotnetdud.


OpenFileDialog in Visual Basic .Net
2007-06-23 22:14:00
List Files in Visual Basic .Net / Visual Basic 2005The Visual Basic 6.0 DirListBox control has been rendered obsolete by the OpenFileDialog and SaveFileDialog components in Visual Basic 2005.Conceptual DifferencesThe Visual Basic 6.0 DirListBox control was typically used to display directories and paths in a File Open or Save dialog box.In Visual Basic 2005, the Windows Forms OpenFileDialog and SaveFileDialog components provide the ability to create standard Windows dialog boxes for working with files, in most cases eliminating the need for the DirListBox control.For this example, Let us have a form with a TextBox and a command button. When the command buton is pressed, the folderdialog is shown and then the selected folder is displayed in the textboxSample Form:Add the FolderBrowser Dialog to the form from the Dialogs Collection (see below).This control will not be placed on the form but on a separate tray at the bottom of the Windows Forms Designer. (see below)Now in the click event


Selecting a Folder in VB.Net
2007-06-23 22:07:00
Directory Selection in Windows Forms using VB.NetThe Visual Basic 6.0 DirListBox control has been rendered obsolete by the OpenFileDialog and SaveFileDialog components in Visual Basic 2005. If you want to select a directory Folder Browser Dialog will be the one you need to useFor this example, Let us have a form with a TextBox and a command button. When the command buton is pressed, the folderdialog is shown and then the selected folder is displayed in the textboxSample Form:Add the FolderBrowser Dialog to the form from the Dialogs Collection (see below).This control will not be placed on the form but on a separate tray at the bottom of the Windows Forms Designer. (see below)Now in the click event for the Button have the following code:Private Sub BtnFolder_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnFolder.Click Dim MyFolderBrowser As New System.Windows.Forms.FolderBrowserDialog ' Descriptive text displayed above the tree view control in


Directory Size using VB.Net
2007-06-15 20:33:00
Get Folder Size using .NetFor getting the size of each directory in Vb.Net, you need to add up the size of each file in the directory.This function gets the size of each directory including sub-directories and writes to a text fileImports System.IO Dim oBuffer As System.IO.TextWriter Function Get_Directory _Size(ByVal sDirPath As String) Dim lDirSize As Long Dim oDir As DirectoryInfo Dim sDir As DirectoryInfo Dim sFiles As FileInfo Dim iFN As Short '* File Number Dim sPath As String '* Saving Path 'Dim oFSW As System.IO.FileSystemWatcher oDir = New DirectoryInfo(sDirPath) Dim oDirs As DirectoryInfo() = oDir.GetDirectories() For Each sDir In oDirs lDirSize = 0 For Each sFiles In sDir.GetFiles("*.*") lDirSize += sFiles.Length Next'--------------------------------------------------------' Coded by Shasur for http://dotnetdud.blogspot.com/'-----


VB.Net Setting Default & Cancel Buttons
2007-06-08 21:56:00
Setting Default & Cancel Buttons in Visual Basic.Net FormDefault button is in VB.NEt with a different name - AcceptButton. However, cancel button retains its name:Here is a way you can set them Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load 'Sets cmdOK as the button control that is clicked when the user presses the Enter key. Me.AcceptButton = cmdOK 'Sets cmdCancel as the button control that is clicked when the user presses the ESC key. Me.CancelButton = cmdCancel End SubFor setting the same in VBA/VB refer : http://vbadud.blogspot.com/2007/06/setting-default-cancel-buttons-in.html
Read more: Setting

VB.Net Form Close vs Form Dispose
2007-06-08 21:02:00
Two methods doing some identical jobs always create some confusion. What to use to 'unload' the form Form.Close or Form.DisposeForm.Close should be the answer as going by Microsoft Form.Close disposes the form as well if the form Modeless .One more advantage you get from this method is from the events that are associated with the formYou can prevent the closing of a form at run time by handling the Closing event and setting the Cancel property of the CancelEventArgs passed as a parameter to your event handler. Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing If MessageBox.Show("Form is closing", "Form Close", MessageBoxButtons.YesNo, MessageBoxIcon.Hand) = Windows.Forms.DialogResult.No Then e.Cancel = True End If End SubThe above prevents the form being closedWhen the form is opened as Modal form (using Showdialog) you can dispose the form explicitly RSS Feeds Submis


Opening & Closing Forms in .Net
2007-06-08 20:51:00
Opening & Closing the forms have changed from Visual Basic 6.0 to VB.NetThe Form object in Visual Basic 6.0 is replaced by the Form class in Visual Basic 2005. The names of some properties, methods, events, and constants are different, and in some cases there are differences in behaviorForm1.Show Modal=True in VB 6.0 is replaced with the ShowDialog Sub Show_Form_Modal() Form1.ShowDialog() ' Modal End Sub Sub Show_Form_Modeless() Form1.Show() ' Modeless End SubClosing which was done by Unload(Me) Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Me.Close() End Sub
Read more: Forms

ASP.Net Get User / .Net Get User
2007-06-07 21:45:00
User names are the most important ones. Whether to write in logs or display a warm hello message, it is there throughoutHere let us look at the way to get the user of the system. Webdevelopemt will have different 'users'. Function Get_User_Name() As String Return My.User.Name End Function BlogRankings.comAgain the My namespace comes in handyThe same can be done using VBA :http://vbadud.blogspot.com/2007/05/get-computer-name.htmlFor knowing the user using SQL select statement please refer :


Get Computer Name in .Net
2007-06-07 21:43:00
Use the My object to get the name of the computer ' Returns Name of the Computer Function Get_Comp_Name() As String Return My.Computer.Name.ToString End FunctionThe VBA/Visual Basic function to do the same is :http://vbadud.blogspot.com/2007/05/get-computer-name.htmlThe SQL Statement to get the computer name is :http://sqldud.blogspot.com/2007/04/get-computer-name-from-sql-query.htmlChanging LINKS


Get Day of the Week
2007-04-08 07:32:00
A simplest function to get the day of the weekSub DisplayTime() MessageBox.Show(GetTime)End SubFunction GetTime() As String If My.Computer.Clock.LocalTime.DayOfWeek = DayOfWeek.Saturday Or _ My.Computer.Clock.LocalTime.DayOfWeek = DayOfWeek.Sunday Then Return "Happy Weekend!" Else Return "Happy Weekday! Don't work too hard!" End IfEnd FunctionWeb Links DirectoryAddMe - Search Engine OptimizationFree Search Engine Submission


Public Variables in VB.Net
2007-10-30 21:18:00
Declaring Public Variables in Visual Studio .NetLast week when I had a chat with Sharmila Purushotaman, she told that one of the frequent query she gets is about the scope of the variables. She wanted me to share the information (and gave the following hint too). Here we go:Application Name : SampleCreate a separate module as PublicVariables.VB (This is a Module)Create a frmSample.vb (This is a form)In the beginning of frmSample(Code Module) include this statement.Imports Sample.PublicVariables (Before the statement Public Class frmSample)All thats needed was to create a separate module (though not mandatory ... it would be a best practice to do so) and declare the variables and use the Imports statement to use the variable in the subsequent classes or modules


Split Function in Visual Basic .Net
2007-12-23 20:38:00
Split Function returns a zero-based, one-dimensional array containing a specified number of substrings. Function DND_Split_Example() Dim arTempVB2005() As String Dim arTempVB6() As String Dim arTempSpace() As String Dim sSplitString As String sSplitString = "MyName||MyAge||MySex" arTempVB2005 = sSplitString.Split("||") arTempVB6 = Microsoft.Visual Basic .Split(sSplitString, "||") arTempSpace = Split("Split By Spaces") End Function Here are the overloaded examples of Split Function Split Call Return Value Split("42, 12, 19") {"42," , "12," , "19"} Split("42, 12, 19", ", ") {"42", "12", "19"} Split("42, 12, 19", ", ", 2) {"42", "12, 19"} Split("192.168.0.1", ".") {"192", "168", "0", "1"} Split("Alice and Bob", " AND ") {"Alice and Bob"} Split("Alice and Bo
Read more: Visual Basic

Visual Studio Immediate Window
2007-12-23 20:34:00
Immediate and Command window in Visual Studio The Command window is used to execute commands or aliases directly in the Visual Studio integrated development environment (IDE). You can execute both menu commands and commands that do not appear on any menu. To display the Command window, choose Other Window s from the View menu, and select Command Window The Immediate window is used to debug and evaluate expressions, execute statements, print variable values, and so forth. It allows you to enter expressions to be evaluated or executed by the development language during debugging. To display the Immediate window, open a project for editing, then choose Windows from the Debug menu and select Immediate. You can use this window to issue individual Visual Studio commands. The available commands include EvaluateStatement, which can be used to assign values to variables. The Immediate window also supports IntelliSense. The table below contains a list of the pre-defined aliases that come


Microsoft XP Style Buttons and Controls on Form in .Net
2007-12-23 20:33:00
Change style of Buttons to Microsoft XP Standard using .Net Visual style is the user-modifiable appearance of the user interface of an application or operating system. By default, Windows XP provides a new visual style. The scroll bars and title bar of a Windows Form will automatically use the new visual style when the form is run on Windows XP. If your application calls the EnableVisualStyle s method, most of your Windows Forms controls will automatically use the visual style when your application is run on Windows XP Private Sub frmDND1Main_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Application.EnableVisualStyles() End Sub The same can be achieved in the designer :


Preventing multiple instances of .Net Application
2007-12-23 20:22:00
Single instance application in VB.NetIf you were creating a Windows application, most often you would be doing some database initialization or some network validation before you show up the form to the user. The patient user might wait few seconds to let the form show, others might launch the application again. To avoid user launch multiple instances of the application, select the Make single instance application check box to prevent users from running multiple instances of your application. The default setting for this check box is cleared, allowing multiple instances of the application to be run. You can do this from ProjectàPropertiesàApplication tab


.NET 3.5 Enhancements Training Kit Available for Download
2008-04-29 01:35:00
Download .NET 3.5 Enhancements Training KitThe .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 RTM Top of pageInstructionsDownload and execute the kit. The kit will uncompress to the selected folder and launch a HTML br
Read more: Download

Create Custom Task Panes for Word using VSTO
2008-07-29 20:18:00
How to Create a Word Addin using Visual Studio Creating VSTO Word Addins in using Visual Studio is a simple process Select Project - -> New Project - -> Office - ->Select the Version of Office (Office 2007, Office 2003) - ->Word 2007/2003 Addin VSTO Word AddinThis will create a solution as shown below. A new class will be added with Startup and Shutdown methods VSTO Startup &


Validate Phone Numbers, Zipcode TextBox entry in Vb.NET Used Masked Text Boxes.
2008-07-29 20:15:00
MaskedTextBox Control in VB.NET MaskedTextBoxes can be thought as the extension of MaskedEdit Control of VB6.0. It can be used to validate TextBox input based on ‘Mask’ The MaskedTextBox class is an enhanced TextBox control that supports a declarative syntax for accepting or rejecting user input. Using the Mask property, you can specify the following input without writing any custom va
Read more: Validate , Numbers , Masked

VB.NET Controls - DomainUpDown Example
2008-07-29 20:13:00
DomainUpDown Control in VB.NET The Windows Forms DomainUpDown control looks like a combination of a text box and a pair of buttons for moving up or down through a list. The control displays and sets a text string from a list of choices. The user can select the string by clicking up and down buttons to move through a list, by pressing the UP and DOWN ARROW keys, or by typing a string that match
Read more: Example

Property without a 'ReadOnly' or 'WriteOnly' specifier must provide both a 'Get' and a 'Set'
2008-07-29 20:11:00
Property without a 'ReadOnly' or 'WriteOnly' specifier must provide both a 'Get' and a 'Set' If a property is not declared as ReadOnly or WriteOnly, it must supply procedures for reading and writing its value. Error ID: BC30124 The error comes in the following example as ‘Set’ procedure is not available Public Property MyTaskPane() As Microsoft.Office.Tools.CustomTaskPane G


Reference to a non-shared member requires an object reference
2008-07-29 20:09:00
How to Reference Word/Excel application in a UserControl/TaskPane After creating taskpane (through user control, you will have necessity to process the Word document/ Excel workbook based on events) Imports Word = Microsoft.Office.Interop.Word Public Class UserControl1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Read more: reference

Creating and Sorting Arrays in C#
2008-09-03 08:42:00
private void csharp_array() { string[] arCities = {"","","",""}; arCities[0] = "Zurich"; arCities[1] = "Havana"; arCities[2] = "Amalapuram"; arCities[3] = "San Francisco"; //arnames Array.Sort(arCities); } Array.Sort method sorts the elements in an entire one-dimensional Array using the ICo
Read more: Creating , Sorting

Page 1 of 1 « < 1 > »
eXTReMe Tracker