Please jumpstart my VB.Net experience

  • Thread starter Thread starter AnakinVB
  • Start date Start date
A

AnakinVB

Guest
Hello,
I recently installed VB.NET and Im overwhelmed and intimidated by it. I have experience in VB6 and some classic ASP. I attempted to do my first .NET program and I found myself at sea. I couldnt even get the mainstay "HelloWorld" program to work.
Can someone please give me a starter program to mimmick just so I can get a clue?
thx,
Anankin
 
Hello,
I downloaded that program. I cant believe "Hello World" is that complex on VB.Net. If I had to do this program on my own, I never would have gotten it in a million years. After looking at the code of HelloWorld, Im not sure what to ask first. But here goes:

1) I dont understand what is up with the continuous use of "Class" Class App ? ClassMainForm? Can someone give me an explanation of how this Class declaration works?

2) Is there a VB.NET tutorial somewhere out on the Internet that someone can recommend?

thx,
Anakin
 
Instead of classes being in seperate files, they are marked in code with Class...End Class statements. There is only one filetype for vb.net files so this makes sense. In VB6 youd have a class file, and give it a name, but in vb.net you just stick everything inside a Class...End Class in a file.

The simplest Hello World example would be a console application, with no overhead of a Windows Form:

Code:
Class Class1
    Shared Sub Main()
        System.Console.WriteLine("Hello, World!")
    End Sub
End Class
 
In .NET there are many Walkthroughs you can learn from. Search the help file. There is also some help on understanding Classes.
 
Hey thanks!

When you say "Search the help file" I dont want to misfire on my search. Will it be sufficient ifI search on things like "functions" "classes" ? Anything particular youd recommend?
thx
Anakin
 
if you use keywords like Walkthroughs or Classes, you will get some good results.

Youll appreciate the walkthoughs, allthough they are not very complex, it allows you to build them from the ground up. (as apposed to a sample project which has aleady been completed for you)
 
Hi,

I was at the same stage about three weeks ago (maybe even worse : if I had some programming experience, I had never done anything with any of the Microsoft languages or any Object Oriented Development).

I feel that I begin to understand a few things thanks mainly to :

- Great people on the forums which I have pestered a few times with very naive questions
- a few web sites
- MSDN How Tos : http://msdn.microsoft.com/howto/howto_index.asp
- .Net 247 : http://www.dotnet247.com/247reference/default.aspx
- .Net tutorials and samples : http://samples.gotdotnet.com/quickstart/
- and two books which I found good :
- Microsoft : Visual Basic .net, Step by Step by Michael Halvorson
- Wrox : VB.NET professional

Hope it will help you

Good luck
 
pgerard, thanks for the tutorials.

divil, I tried your Hello World code. It popped open a form but there was no "Hello World." And it was unclear, where I should place that code.

a) Can anyone tell me why this code (below) does not work?

b) Why does the code CHANGE drastically when I paste it into this forum reply window?


Heres what I did:

Code:
Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        This call is required by the Windows Form Designer.
        InitializeComponent()

        Add any initialization after the InitializeComponent() call

    End Sub

    Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    NOTE: The following procedure is required by the Windows Form Designer
    It can be modified using the Windows Form Designer.  
    Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        
        Form1
        
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 273)
        Me.Name = "Form1"
        Me.Text = "Form1"

    End Sub

#End Region

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

    End Sub
End Class

Class Class1
    Shared Sub Main()
        System.Console.WriteLine("Hello, World")
    End Sub
End Class
My God, this is complicated. VB6 is so much simpler!

thx,
Anakin (lost.Net)
 
Last edited by a moderator:
b) Why does the code CHANGE drastically when I paste it into this forum reply window?
Because you need to use the VB tags ....

[ vb ]
your code goes here..... (remove the spaces in the [tags]
[/ vb]
 
Heres a sample, I put a lot more code then is needed only to illustrate classes.
Im very new to .NET as well, Im sure now well see 100 better solutions pop up.

Place the whole thing in the code window of a new form...

Code:
Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        This call is required by the Windows Form Designer.
        InitializeComponent()

        Add any initialization after the InitializeComponent() call

    End Sub

    Form overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    NOTE: The following procedure is required by the Windows Form Designer
    It can be modified using the Windows Form Designer.  
    Do not modify it using the code editor.
    Friend WithEvents Button1 As System.Windows.Forms.Button
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Me.Button1 = New System.Windows.Forms.Button()
        Me.SuspendLayout()
        
        Button1
        
        Me.Button1.Location = New System.Drawing.Point(88, 48)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(104, 40)
        Me.Button1.TabIndex = 0
        Me.Button1.Text = "Button1"
        
        Form1
        
        Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
        Me.ClientSize = New System.Drawing.Size(292, 273)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button1})
        Me.Name = "Form1"
        Me.Text = "Form1"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ms As New hello("Hello World")
        MessageBox.Show(ms.GetMessage())
    End Sub

    Private Sub Form1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
        Dim ms As New hello("Good-Bye World")
        MessageBox.Show(ms.GetMessage())
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        This will demo divils example
        Dim ms As Class1
        ms.Main()
    End Sub
End Class

Class Class1
    Class1 is to demo divils example
    Shared Sub Main()
        System.Console.WriteLine("Hello, World!")
    End Sub
End Class

Public Class hello
    Private msg As String
    Private SpeakOut As String

    Public Property GetMessage() As String
        Get
            Return SpeakOut
        End Get
        Set(ByVal Value As String)
            msg = SpeakOut
        End Set
    End Property

    Sub SetMessage()
        Try
            Dim oMsg As Object = msg
            SpeakOut = oMsg
        Catch
            SpeakOut = ""
        End Try
    End Sub

    Sub ResetString()
        msg = ""
    End Sub

    Sub New(ByVal newMsg As String)
        msg = newMsg
        MyClass.SetMessage()
    End Sub

    Protected Overrides Sub Finalize()
        ResetString()
        MyBase.Finalize()
    End Sub
End Class
 
Back
Top