PDA

View Full Version : Userforms in VB.NET vs. VB6


daveyisu
03-04-04, 11:15 PM
I'm new to VB.NET so I'm having a great deal of difficulty adapting. My VB experience isn't all that deep in general, but I have a good idea for the most part of how the code works. Recently I wrote some code to perform file conversions and also call C .dll files to perform some complex mathematics (Fourier transforms and the like).

I wrote the original code in VB6, but now I want to compile it into an .exe so I was going to use Visual studio .net.

I guess my first question is whether this is my best path for me to take? If there would be an easier way for me to compile my VB6 code into an .exe I'm up for it. If not I'm led into my second question.

I used a userform in VB6 to make the user inputs much clearer. The code also performs three separate functions, so I used options buttons etc. to make this all work. It was easy for me to figure out the syntax for utilizing the form. Part of my code was similar to:

dim inputfile as string
inputfile = userform1.TextBox1.value
Open (inputfile) For Input As #1

This code won't work in .NET as I'm sure you're all aware. Could someone please tell me how I would go about making it comparable?

*Note* The same sort of thing applies to optionbuttons. I realize they are radiobuttons in .NET, but code such as:

If (userform1.optionbutton1.value = true) then

won't compile in .NET.

I realize this post has gotten really long, but I would greatly appreciate any insight.

Thanks ahead of time

David

Shane
03-23-04, 08:07 PM
I'm new to VB.NET so I'm having a great deal of difficulty adapting. My VB experience isn't all that deep in general, but I have a good idea for the most part of how the code works. Recently I wrote some code to perform file conversions and also call C .dll files to perform some complex mathematics (Fourier transforms and the like).

I wrote the original code in VB6, but now I want to compile it into an .exe so I was going to use Visual studio .net.

I guess my first question is whether this is my best path for me to take? If there would be an easier way for me to compile my VB6 code into an .exe I'm up for it. If not I'm led into my second question.

I used a userform in VB6 to make the user inputs much clearer. The code also performs three separate functions, so I used options buttons etc. to make this all work. It was easy for me to figure out the syntax for utilizing the form. Part of my code was similar to:

dim inputfile as string
inputfile = userform1.TextBox1.value
Open (inputfile) For Input As #1

This code won't work in .NET as I'm sure you're all aware. Could someone please tell me how I would go about making it comparable?

*Note* The same sort of thing applies to optionbuttons. I realize they are radiobuttons in .NET, but code such as:

If (userform1.optionbutton1.value = true) then

won't compile in .NET.

I realize this post has gotten really long, but I would greatly appreciate any insight.

Thanks ahead of time

David
In VB6, just go to the "File" menu and then click "Make EXE".

There are quite a few ways you can read text file data in VB.NET. http://www.freevbcode.com/ShowCode.asp?ID=4492 is one example.

For Radio Buttons in VB.NET, use


If optionbutton1.Checked Then
' Do whatever
End If

daveyisu
03-25-04, 03:30 PM
Thanks for the help with the userform. I have that up and running great, but as you can see from my latest post, the ability to read the file correctly is still eluding me.

Thanks again

David

Shane
03-25-04, 04:35 PM
Thanks for the help with the userform. I have that up and running great, but as you can see from my latest post, the ability to read the file correctly is still eluding me.

Thanks again

Davidok, here is the code I took from the link posted and broken down.


Dim strContents As String ' Store the contents of our file
Dim objReader As StreamReader ' Our streamreader is the file i/o handle.

objReader = New StreamReader("C:\MyTextFile.txt") ' Open text file
strContents = objReader.ReadToEnd() ' Read the entire file and place the contents in the strContents variable.
objReader.Close() ' Close file



Also, don't forget to import the System.IO namespace at the top like:


Imports System.IO