Guest meoabc Posted September 16, 2002 Posted September 16, 2002 Hello I'm starting to learn VB.Net When working with ADO I have to declare some objects and variables. There are some syntax in declare statements that I don't understand, for example: Dim Reader1 As SQLClient.SQLDataReader (1) Dim DataAdapter As New sqlClient.SqlDataAdapter() (2) Dim myCommand As New SqlCommand(sqlSelect, myConnection) (3) Reader1 = New Command1.ExecuteReader (4) ..... I don't know - When to use "As" like in (1) - When to use "As New" and in this case when I can have no parameter like in (2) or when I can have parameter like in (3) - When to use "= New" like in (4) Thanks for any help Quote
*Gurus* Thinker Posted September 16, 2002 *Gurus* Posted September 16, 2002 You don't use As New when you don't need to create an instance of the object at the same time you are declaring the variable. You do use As New when you do need to create an instance of the object, so you might just as well do it at the start. Parameters for As New statements depend on the constructor(s) defined for the class. Intellisense should let you know what constructors can be used, and what the parameters (if any) can be passed. Quote Posting Guidelines
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.