Showing posts with label Visual Basic. Show all posts
Showing posts with label Visual Basic. Show all posts

Tuesday, August 24, 2010

Input Validation in VB.Net

Friday, April 23, 2010

Opening Another Program in VB.NET

Hey I got this code from the website www.dreamincode.net/forums


Try
Dim p As New System.Diagnostics.Process
'the location of your program
p.StartInfo.FileName = "K:\Uni\Year 2\Visual Basic\Report\MSDN\Absolute Beginner's Series VB Lesson 1\01 VB Code\Lesson01\HelloWorld.exe" 
p.Start()
Catch ex As Exception
MsgBox("Error - " + ex.Message)
End Try

This can be useful in opening other applications (especially Microsoft VB.NET applications). The problems is that there are chances of error especially when the program is missing, or the program has been moved.


As a solution to that problem, I suggest that you would make the separate application relative to your executable file so that
moving the whole project to another location whould not affect the path you specified.
Your file path should look like this.
p.StartInfo.FileName = "Your Program.exe"  'your relative path, no need to include the drive location for portability

Just make sure that the program is located beside the program you are debugging.
You can do this by adding another project as a reference to your main project so that everytime you compile, the executables automatically
proceed to the bin where they would reside as they are executed.
To add a refecence, you can follow these steps:

If the other program (VB Project) is not yet part of the Solution:
1. go to File > Add Existing project
2. Then select the project file of the program you want to link it with.
You will notice in the solution explorer that another project is added.

Now, you can make that program part of the main program by adding it as a reference.
On your solution explorer, right click your main project, Choose Add reference.

As the add reference dialog opens, choose projects then select the project file of the other program.

Add Reference
Pro VB 2008 and the .NET 3.5 Platform (Windows.Net)
Pro VB 2008 and the .NET 3.5 Platform (Windows.Net)

Saturday, April 3, 2010

STEPS IN INTEGRATING HELP FILE IN YOUR VB.NET APPLICATION

1. Place this code inside your sub-menu (when clicked under main menu or button if you choose it instead). Make sure you follow the syntax below:

Help.ShowHelp(Me, [url]);
  • Since you use VB as programming language, it should be 'Me' not 'this' because ‘this’ is for C#. By the way, what does it mean is ‘Me’ is your main form which will become the parent of the newly opened help file (in your case, your pdf file).
  • Next parameter is ‘url’. In this type of parameter, it requires you to input the whole directory together with your pdf file.. For example, your help file is sample.pdf located at 'c:\program files\system'. Just add sample.pdf at the end of 'c:\program files\system' which becomes 'c:\program files\system\sample.pdf'.

So the final output of your ShowHelp() method is:

Help.ShowHelp(Me, "c:\program files\system\sample.pdf");


But there is one problem on this method if you install it in your client's computer; there is a possibility that his/her computer’s directories are different from yours. So if that's the case, follow this:

1. Place your sample.pdf file inside your project's bin-->debug folder (and bin-->release folder if there is) found in your project folder.

2. Then change your code into this

Help.ShowHelp(Me, Path.GetFullPath("sample.pdf"))

For example this is your whole code


--> You need to import System.IO at the top of your code, like this
Imports System.IO




NOTICE:
  • This tutorial will work only in Microsoft Visual Studio esp. 2008 (not sure in 2003 and 2005 because I used Path class which I don’t know if existing in .NET 1.1 and .NET 2.0). 2008 uses .NET 3.5.
  • I notice that chm, doc and pdf files will open once after clicking the button or submenu under main menu while txt will open as many times you click it.

Hope that helps! =) Always here to post useful tutorials for you guys!

Thursday, March 18, 2010

SharpDevelop: Open Source Visual Studio .NET

Fot those who are looking for an alternative IDE for Microsoft Visual Studio .NET, something that costs less (actually free), and does not require a lot of hardware specification, this this article may be of help.

SharpDevelop is a free IDE that imitates the user interface of Microsoft Visual Studio. It contains a lot of features similar to Visual Studio such as the project explorer, drag-and-drop design view, resource manager, syntax highlighting... etc. It uses the free distributable .NET Framework for compiling source codes. (So it requires .NET Framework installed first)


 


SharpDevelop may not posses the same quality and features which may be found at Microsoft Visual Studio but this could also be a good option for starters especially in Visual Basic and C# Programming. Users who are already used to may not feel comfortable because of some features. However, projects in SharpDevelop may still be opened in MS Visual Studio.

sharpdevelop


SharpDevelop may be downloaded at
icsharpcode.net



Latest Version for Microsoft .NET Framework
.NET Framework Page