Helloworld program

Greenknight

Member
Joined
Sep 26, 2007
Messages
9
Programming Experience
Beginner
Greetings,

I have a problem with a tutorial I was working on and I was wondering if this is the correct place to put it. The tutorial is on a hello world program, I'm trying to do.

sincerely,

gk
 
sure you can... "the hello world" application is usually the first every programmer starts with... what is your problem?

you just have to drag a "button" control into the design area... double click it

it should go to the code area...

then write this on the event button1_onclick:

msgbox("Hello World")
 
The tutorial is here.
 

Attachments

  • HelloWorldv2.JPG
    HelloWorldv2.JPG
    147.7 KB · Views: 67
Looks like you need to declare something before your public class, i.e.

Imports HelloWorld

...it may be a reference you need to do. The link you provided doesn't show a HelloWorld tutorial to check if that's the case, although I may be missing something on there!!
 
Well, okay I went back and looked at the code and found some things, then I compared it to the code that was downloaded and found more things. Anyway, I'm still have one bug though. I was thinking perhaps I missed something in some of the other windows?
 
Ok, here's your problem. You have just copied and pasted the code from the posted article into your program. This is not a good idea from the start... apart from the fact that copying event handlers introduces it's own problems, it won't help you learn.

Start again, here's what you do....

On your form in design mode place the controls onto the form from the toolbox to the postions they are in that image on that tutorial. Make sure to name them in the properties window. For example the top radio button you should call 'English' Then when you double click it from the designer it will open up the Checked Changed event handler for that control. Do that for each control including the button making sure to add the code for each event handler. Thepart you can't see in that tutorial is the hellomodule.vb page.In there you would find a static method that read something like this...

VB.NET:
Friend Shared Sub ShowHello(Byval Language As String)

MessageBox.Show("Hello World", Language)

End Sub

To be honest it's not a very good tutorial.
 
Well, I did go back through the tutorial, that's how I found figured out the errors but I still have one left. It might not be a very good tutorial, but it's all I have right now. I've read a bunch of Visual Basic basic books, but I want to learn from books and tutorials that are made for visual basic express. I might get confused with other books because they might have features that visual basic doesnt' have.

Module HelloModule
Sub SayHello(ByVal HelloLanguage As String)
Select Case HelloLanguage
Case "English"
HelloWorld.HelloworldLabel.Text = "Hello World"
Case "Espanol"
HelloWorld.HelloworldLabel.Text = "Hola Mundo"
Case "Deutsch"
HelloWorld.HelloworldLabel.Text = "Hallo Welt"
Case Else
HelloWorld.HelloworldLabel.Text = "Error/Error/Fehler"
End Select
End Sub
End Module

T
 
Whats the error message say? Anyway you'd be better of returning the string to the main class in a function...

VB.NET:
Module HelloModule
Function SayHello(ByVal HelloLanguage As String) As String
Dim RetStr as String = String.Empty
Select Case HelloLanguage
Case "English"
RetStr = "Hello World"
Case "Espanol"
RetStr = "Hola Mundo"
Case "Deutsch"
RetStr = "Hallo Welt"
Case Else
RetStr = "Error/Error/Fehler"
End Select

Return RetStr
End Sub
End Module

From the calling Routine...

VB.NET:
HelloWorld.HelloworldLabel.Text = SayHello(Language)
 
Error 1 Handles clause requires a WithEvents variable defined in the containing type or one of its base types.

I'm sure there are tons of better ways to do this, but being new I got to start small. Right now I just want to fix that one error.
 
VB.NET:
Public Class HelloWorld
    Dim Language As String
    Private Sub Display_Click( _
        ByVal sender As System.Object, _
        ByVal e As System.EventArgs) _
        Handles DisplayHello.Click
        HelloModule.SayHello(Language)
    End Sub
    Private Sub English_CheckedChanged( _
        ByVal sender As System.Object, _
        ByVal e As System.EventArgs) _
        Handles English.CheckedChanged
        Language = "English"
    End Sub
    Private Sub Espanol_CheckedChanged( _
        ByVal sender As System.Object, _
        ByVal e As System.EventArgs) _
        Handles Espanol.CheckedChanged
        Language = "Espanol"
    End Sub

    Private Sub Deutsch_CheckedChanged( _
        ByVal sender As System.Object, _
        ByVal e As System.EventArgs) _
        Handles Deutsch.CheckedChanged
        Language = "Deutsch"
    End Sub
End Class
 
Back
Top