Jump to content
Xtreme .Net Talk

Please jumpstart my VB.Net experience


Recommended Posts

Guest AnakinVB
Posted

Hello,

I recently installed VB.NET and I'm 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 couldn't 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

Guest AnakinVB
Posted

Hello,

I downloaded that program. I can't 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, I'm not sure what to ask first. But here goes:

 

1) I don't 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

  • *Gurus*
Posted

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 you'd 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:

 

Class Class1
   Shared Sub Main()
       System.Console.WriteLine("Hello, World!")
   End Sub
End Class

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Guest AnakinVB
Posted

Hey thanks!

 

When you say "Search the help file" I don't want to misfire on my search. Will it be sufficient ifI search on things like "functions" "classes" ? Anything particular you'd recommend?

thx

Anakin

  • Moderators
Posted

if you use keywords like 'Walkthroughs' or 'Classes', you will get some good results.

 

You'll 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)

Visit...Bassic Software
Posted

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

  • 2 weeks later...
Guest AnakinVB
Posted (edited)

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?

 

 

Here's what I did:

 

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)

Edited by Robby
  • Moderators
Posted
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]

Visit...Bassic Software
  • Moderators
Posted

Here's a sample, I put a lot more code then is needed only to illustrate classes.

I'm very new to .NET as well, I'm sure now we'll see 100 better solutions pop up.

 

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

 

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

Visit...Bassic Software

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...