VB.NET

Check if a Program is being installed or not?

16/12/2009 12:11
Private bInstalled As Boolean Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load        Try            Dim oApp As Object = CreateObject("Outlook.Application")         ...

Folder activity in vb.net

20/11/2009 10:40
Watching File/Folder Activity in VB.NET posted ‎‎Sep 18, 2009 1:17 AM‎‎ by thiyagaraaj Mr   [ updated ‎‎Sep 18, 2009 1:19 AM‎‎ ] Contents 1 Introduction 2 Getting...

VB.NET 2003 and 2005 snippets

18/11/2009 14:05
Add 'all' Date/Time Formats to Listbox/Combobox         'Should add all of the available Date and Time formats to a combobox or listbox control.           Dim dateTime As DateTime = New...

Shutdown/Restart/Logoff your PC using TweetMyPC

31/07/2009 15:39
In this article I will show you how you can use Twitter API to Shutdown/Restart/Logoff your PC remotely using VB.net. Compiled version: CodePlex.com Source Code: Codeplex.com Difficulty: Beginner Time Required: 2 hours Cost: Free Software Needed: Visual Basic or Visual C#...

VB.net Forum

Date 20/11/2009

By denz

Subject fading form

Reply

While core functionality and useability of the application is always one of the most important aspects, various visual effects may improve the way users feel about a particular application. Even though you may be able to implement purely cosmetic features in an application, it's important to keep the functionality in mind.

In this VB.NET tip, I will show you a way to give users a form that fades out when it's closed. This isn't a must-have functionality for applications, but I think this feature is often nice to have so that an application closing doesn't look abrupt.

Form fade out

In order to make the form fade out, I use the Form's Opacity property. By default, the Form's Opacity equals 1. To let the form fade out, I create a look to gradually decrease the Form's Opacity value until I finally close the form.

Example

To try this out, add a button to the form and add the following code to its click event:

Private Sub FadingForm()

Dim iCount As Integer

For iCount = 90 To 10 Step -10
Me.Opacity = iCount / 100
Me.Refresh()
Threading.Thread.Sleep(50)
Next

Me.Close()

End Sub

Then add the following code to the Form_Load event:

Me.Opacity = 0.99

How it works

On the Form_Load event, I set the Form's Opacity to 0.99 (or 99%). This is because, on some computers, the code provided would initially create a blink and then let the form fade out. This usually happens when the Form's Opacity is lowered from 1 down. To prevent this blink before the fade out effect, I set the Form's Opacity to 0.99 (the difference is not visible to the user) and then fade the form out.

Date 20/11/2009

By denz

Subject readin and writing txt file in vb.net

Reply


Reading and writing text files with VB.NET
By Bruce Walton, Builder.com | 2002/08/13 14:10:00

Tags: .net, coding, microsoft .net, programming, text files, vb, vb.net, windows programming
Change the text size: a | A

* Print this
* E-mail this
* Leave a comment
* Clip this
* del.icio.us Digg Reddit Slashdot StumbleUpon DZone

Close

Please login or sign up to clip this article.
E-mail
Password
Remember meLogin
Log in | Sign up | Why join Builder AU's community? See the benefits.

Please login or sign up to clip this article.
E-mail
Password
Remember me Login
Reading and writing text files is an essential task in any programming language. Follow this step-by-step approach to working with text files in VB .NET.

Years ago, when I first learned to program in BASIC, I came across a sample program for reading a text file. The OPEN command with the file number looked quite confusing, so I never wrote the program. Later, when I learned Visual Basic, I was shocked to see that the same file operations existed in VB. The basic file-handling commands had not changed; just a few more features had been added.

With Visual Basic .NET, Microsoft introduced a new, object-oriented method for working with files. The System.IO namespace in the .NET framework provides several classes for working with text files, binary files, directories, and byte streams. I will look specifically at working with text files using classes from the System.IO namespace.

Basic methods
Before we jump into working with text files, we need to create a new file or open an existing one. That requires the System.IO.File class. This class contains methods for many common file operations, including copying, deleting, file attribute manipulation, and file existence. For our text file work, we will use the CreateText and OpenText methods.

WEEKLY .NET HOW-TOS

New .NET tutorials updated every Thusday with Cast Your .NET

CreateText
True to its name, the CreateText method creates a text file and returns a System.IO.StreamWriter object. With the StreamWriter object, you can then write to the file. The following code demonstrates how to create a text file:
Dim oFile as System.IO.File
Dim oWrite as System.IO.StreamWriter
oWrite = oFile.CreateText(“C:\sample.txt”)
OpenText

The OpenText method opens an existing text file for reading and returns a System.IO.StreamReader object. With the StreamReader object, you can then read the file. Let’s see how to open a text file for reading:
Dim oFile as System.IO.File
Dim oRead as System.IO.StreamReader
oRead = oFile.OpenText(“C:\sample.txt”)
Writing to a text file

The methods in the System.IO.StreamWriter class for writing to the text file are Write and WriteLine. The difference between these methods is that the WriteLine method appends a newline character at the end of the line while the Write method does not. Both of these methods are overloaded to write various data types and to write formatted text to the file. The following example demonstrates how to use the WriteLine method:
oWrite.WriteLine(“Write a line to the file”)
oWrite.WriteLine() ‘Write a blank line to the file
Formatting the output

The Write and WriteLine methods both support formatting of text during output. The ability to format the output has been significantly improved over previous versions of Visual Basic. There are several overloaded methods for producing formatted text. Let’s look at one of these methods:
oWrite.WriteLine(“{0,10}{1,10}{2,25}”, “Date”, “Time”, “Price”)
oWrite.WriteLine(“{0,10:dd MMMM}{0,10:hh:mm tt}{1,25:C}”, Now(), 13455.33)
oWrite.Close()

The overloaded method used in these examples accepts a string to be formatted and then a parameter array of values to be used in the formatted string. Let’s look at both lines more carefully.

The first line writes a header for our report. Notice the first string in this line is {0,10}{1,10}{2,25}. Each curly brace set consists of two numbers. The first number is the index of the item to be displayed in the parameter array. (Notice that the parameter array is zero based.) The second number represents the size of the field in which the parameter will be printed. Alignment of the field can also be defined; positive values are left aligned and negative values are right aligned.

The second line demonstrates how to format values of various data types. The first field is defined as {0,10:dd MMMM}. This will output today’s date (retrieved using the Now() function) in the format 02 July. The second field will output the current time formatted as 02:15 PM. The third field will format the value 13455.33 into the currency format as defined on the local machine. So if the local machine were set for U.S. Dollars, the value would be formatted as $13,455.33.

Listing A shows the output of our sample code.

Listing A

Date Time Price
22 July 10:58 AM $13,455.33


Reading from a text file
The System.IO.StreamReader class supports several methods for reading text files and offers a way of determining whether you are at the end of the file that's different from previous versions of Visual Basic.

Line-by-line
Reading a text file line-by-line is straightforward. We can read each line with a ReadLine method. To determine whether we have reached the end of the file, we call the Peek method of the StreamReader object. The Peek method reads the next character in the file without changing the place that we are currently reading. If we have reached the end of the file, Peek returns -1. Listing B provides an example for reading a file line-by-line until the end of the file.

Listing B

oRead = oFile.OpenText(-C:\sample.txt")

While oRead.Peek <> -1
LineIn = oRead.ReadLine()

End While

oRead.Close()


An entire file
You can also read an entire text file from the current position to the end of the file by using the ReadToEnd method, as shown in the following code snippet:
Dim EntireFile as String
oRead = oFile.OpenText(“C:\sample.txt”)
EntireFile = oRead.ReadToEnd()

This example reads the file into the variable EntireFile. Since reading an entire file can mean reading a large amount of data, be sure that the string can handle that much data.

One character at a time
If you need to read the file a character at a time, you can use the Read method. This method returns the integer character value of each character read. Listing C demonstrates how to use the Read method.

Listing C

Dim intSingleChar as Integer

Dim cSingleChar as String

oRead = oFile.OpenText(-C:\sample.txt")

While oRead.Peek <> -1

intSingleChar = oRead.Read()

' Convert the integer value into a character

cSingleChar = Chr(intSingleChar)

End While

Tap into the power
We've barely scratched the surface of the new file functionality included in .NET, but at least you have an idea of the power now available in the latest edition of Visual Basic .The abilities of the classes in the System.IO namespace are quite useful, but if you want to continue to use the traditional Visual Basic file operations, those are still supported.

source:https://www.builderau.com.au/program/vb/soa/Create-a-temp-file-with-VB-NET/0,339028462,339280583,00.htm

Date 31/07/2009

By stan

Subject best website for vb.net

Reply

https://blogs.msdn.com/coding4fun/

Date 31/07/2009

By Administrator

Subject How to create a Run in vb.net

Reply

In the declaration section, here is the code:
Dim proc as new process()

In the Ok Button, do this:
proc = process.start(textbox1.text)

In the Cancel Button, do this also:
end