Windows Phone Developers

Showing posts with label Dot Net. Show all posts
Showing posts with label Dot Net. Show all posts

Tuesday, October 30, 2007

Public Variables in VB.Net

Declaring Public Variables in Visual Studio .Net

Last 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 : Sample

Create 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 Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

Saturday, June 23, 2007

Selecting a Folder in VB.Net

Directory Selection in Windows Forms using VB.Net

The 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 FolderBrowser Dialog will be the one you need to use

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 textbox

Sample 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 the dialog box
MyFolderBrowser.Description = "Select the Folder"

' Sets the root folder where the browsing starts from
'MyFolderBrowser.RootFolder = Environment.SpecialFolder.MyDocuments

' Do not show the button for new folder
MyFolderBrowser.ShowNewFolderButton = False

Dim dlgResult As DialogResult = MyFolderBrowser.ShowDialog()

If dlgResult = Windows.Forms.DialogResult.OK Then
txt_watchpath.Text = MyFolderBrowser.SelectedPath
End If

End Sub


The FolderBrowserDialog component is displayed at run time using the ShowDialog method. Set the RootFolder property to determine the top-most folder and any subfolders that will appear within the tree view of the dialog box. Once the dialog box has been shown, you can use the SelectedPath property to get the path of the folder that was selected


For similar functionality in VB6.0 refer http://vbadud.blogspot.com/2007/04/browse-folder-select-folder-thru-shell.html

When a Visual Basic 6.0 application is upgraded to Visual Basic 2005, any existing DirListBox controls are upgraded to the VB6.DirListBox control that is provided as a part of the compatibility library (Microsoft.VisualBasic.Compatibility). Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

Friday, June 8, 2007

Opening & Closing Forms in .Net

Opening & Closing the forms have changed from Visual Basic 6.0 to VB.Net

The 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 behavior


Form1.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 Sub

Closing 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


Top Computers blogs Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

Thursday, June 7, 2007

ASP.Net Get User / .Net Get User

User names are the most important ones. Whether to write in logs or display a warm hello message, it is there throughout

Here 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.com

Again the My namespace comes in handy

The same can be done using VBA :
http://vbadud.blogspot.com/2007/05/get-computer-name.html

For knowing the user using SQL select statement please refer : Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

Get Computer Name in .Net

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 Function

The VBA/Visual Basic function to do the same is :
http://vbadud.blogspot.com/2007/05/get-computer-name.html

The SQL Statement to get the computer name is :
http://sqldud.blogspot.com/2007/04/get-computer-name-from-sql-query.html



Changing LINKS
Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

Sunday, April 8, 2007

Get Day of the Week

A simplest function to get the day of the week

Sub DisplayTime()
MessageBox.Show(GetTime)
End Sub

Function 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 If
End Function

Web Links Directory
Submit your website to 20 Search Engines - FREE with ineedhits!




AddMe - Search Engine Optimization


Visual Basic .Net Tips & Tricks, VS.Net 2003, VB 2005 Tips, .Net Code Downloads



Free Search Engine Submission

Free Search Engine Submission

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon