Help me go from PHP to VB.net.
August 21, 2008 10:58 PM
Subscribe
Help me go from PHP to VB.net.
I know PHP. I want to learn VB.net. Since I'm used to understanding basic concepts in one way, I'm having a hard time in VB.net rethinking things. Here are my specific questions:
- In PHP, if I want to call a method (I know, in PHP they're called functions, but go with me here), I use "Method_Name(Parameters_If_Any);". And that is always the syntax. But in VB.net, it seems to change. For example, "Console.WriteLine(strMyString)" is a method that prints something to the current console. But "myObject.GetType()" is also a method that gets the type of an object. In this second example, the function comes last, after an object, and there are no parameters. How do I know when to use which syntax? That doesn't make sense to me. What am I missing here?
- In VB.net, when I dimension a variable, I have to declare its type and its value. That makes sense to me. For example, "Dim strMyString as String = "This is a string"". But I don't understand how/why you would dimension a *variable* as an object. For example, "Dim variable As System.DBNull = System.DBNull.Value". What the heck does that mean? I'm dimensioning a variable as an object and initializing its value to another object?
- In VB.net, why do I sometimes dimension a variable as an object without creating a new instance (i.e., "Dim variable as Object") and sometimes I dimension a variable as an object by creating a new instance (i.e. "Dim variable as New Object").
Again, I'm brand spanking new to VB.net. I've got what seems to be a pretty good book, but these are just some stuff I'm having trouble wrapping my brain around that the book isn't specifically explaining. Sorry if I've used any incorrect syntax or terminology. Like I said, brand new, complete VB.net dummy. Go easy on me.
Any great newbie articles, blog posts, web series, books, videos, etc. that you might recommend? FYI: I'm much more interested in learning the actual code/syntax than I am in learning how to use an IDE to get around coding.
posted by JPowers to computers & internet (10 comments total)
3 users marked this as a favorite
In the first example, "WriteLine" comes after (is called on) an object, "Console", which represents the current console. This particular method takes one argument, the string to be displayed. In the second, you call the method "GetType" on "myObject". It so happens that GetType has no parameter.
To know whether a method takes 0, 1, 2, or N arguments, you have to check the documentation, just like you would in PHP. If you're using an IDE, a parameter list should appear once you're typed the method name.
posted by Monday, stony Monday at 12:29 AM on August 22, 2008