Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Some Basic Questions - New to VB.net

Status
Not open for further replies.

aviles1973

Programmer
May 19, 2002
25
US
I have been programming in VB6 for a long time. I pretty much
mastered database programming in VB6 using ADODC & DAO. I bought VB.net because I was long awaiting the next Visual Basic release. However some forums have told me to stay with VB6. I want to switch my knowledge to VB.net because it is the most current. Could someone please answer the following question.

1) Is it recommended to use VB.net for windows stand alone programs?

2) What happened to Modules (ex. Module.bas)
I used to store all my Global variables here.
Is the global statement still used or how do you
do that now in VB.net

3) Can I still declare recordsets.
Set CustomerRS AS ADODC RECORDSET

 
Changing to VB.Net from VB6 is not a natural progression with just a few extra functions thrown in. It is a whole new development language and you need to be familiar with the concept of OOP.

Modules are still available. Add New to a Project and select Modules. You can still use these to save all your global variables.

In the .NET Framework, you can access existing components that return ADO Recordset or Record objects, and you can also access ADO Recordset and Record objects directly using the .NET Framework Data Provider for OLE DB. The .NET Framework Data Provider for OLE DB supports filling a DataSet from an ADO Recordset or Record. This enables you to consume existing Component Object Model (COM) objects that return ADO objects, without having to rewrite them entirely using the .NET Framework.



Sweep
...if it works dont mess with it
 
Take a look at DataSets and DataViews. They are much better then the old ADO, but take a lot of getting used to.

You will have to rething your projects. It's a bit different. I've been at it for 6mon now, and I'm just getting the hang of the new language.
 
"1) Is it recommended to use VB.net for windows stand alone programs?"

If you interact with MS Office products, VB.net is the best choice. I've heard that the US Navy is starting to develop heavily in VB.net.

2) What happened to Modules (ex. Module.bas) I used to store all my Global variables here. Is the global statement still used or how do you do that now in VB.net.

Modules are still there, it's just that all of the components end with a *.vb extention. They basically work the same way they did before. You can write "Call Subroutine" or you can write modMyModule.Subroutine.

Globals still exist, but since it's all object oriented, the declaration statements are a little different. For me, this is one of the hardest things to get used to. Also, sting manipulation really blows because they no longer have the Left(string, n) or Right(strin, n) methods.

There are a few other things that they seemed to make harder instead of easier, but overall, since Windows is going to be almost all .NET in the future, I think you made the right move.

3) Can I still declare recordsets. Set CustomerRS AS ADODC RECORDSET.

No recordsets as far as I know. They're caled Datasets and they're different animals, but when you use the Dataview method in conjunction with it, it's basically boils down to the same thing.

ds1 = New DataSet
ds1.Clear()

Form1.oleDA.SelectCommand.CommandText = "SELECT * from MYTABLE"
Form1.oleDA.Fill(ds1, "MyDataSet")
dV = New DataView(ds1.Tables("MyDataView"))

For i = 0 To dV.Count - 1
(assign dataset variables to form fields)
Form1.txtTextBox1.Text = Trim(dV(i)(0))
Form1.txtTextBox2.Text = Trim(dV(i)(1))
Form1.txtTextBox3.Text = Trim(dV(i)(2))
Next i

Also, when you're executing an Add, Update, or Delete command, this worked for me:

cmd = New OleDb.OleDbCommand(CommandString, Form1.OleDbConnection1)
cmd.ExecuteNonQuery()

Hope this wasn't over kill. Be leery of typos in my example code. Cheers.
 
RoguePoet01,

The Left and Right string methods are still in VB.net, they are part of the Strings class.

From VB6 to VB.net,
Code:
str = Left("Test String",4)
becomes
Code:
str=Strings.Left("Test String",4)

This is the new object oriented way of doing things. Since there may be methods that share the same name, you explicitly define which method you are referring to.

This may seem "harder" to some, but once you become comfortable with the object-oriented way, I don't believe you'll want to change back, I know I wouldn't.

-Stephen Paszt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top