Hi there,
I am just beginner of learing visual studio 2005. I am trying to learn how to write programming using vb 2005. As a starter, I am tryinng to type and run a very small program following "Getting Started" instructions. I open a new project, write the code and the debugged. Now errors are shown but I am still not getting the output/results.
The result should show "message box" but they are not coming. Can any body help me please..........
AlanPosted Nov 3, 2007, 5:32 PM
Hi Lokman,
There's very little to choose in capabilities between VB.Net and C#, both of which are fully object-oriented. In my opinion the former is easier to use but the latter has more 'power user' features.
Both languages should be able to cope equally well with the simulation model which you have in mind.
So I think it boils down to which language you feel most comfortable with. If I were you, I'd give both a good try before coming down one way or the other.
I'm a bit biased towards C# which has a tighter more precise feel to it than VB.Net and was designed specifically for .NET. On the other hand VB.Net is a descendant of the hugely successful (pre .NET) Visual Basic which, with its English-like syntax, made Windows programming accessible to millions of developers.
Lokman HossainPosted Nov 3, 2007, 4:25 PM
Hi Alan,
This is an excellent communication from your end. I do understand what you mean. I think you are right. There might be problem in installtion of VS 2005. I may re-install the software unless otherwise I can fix the problem.
** My ultimate objective of lerning VB is to develop a simulation model (an objective-oriented program) for my research. My background is Civil Engineering and study field is Project Management specialization. Would you please give your valuable opinion/analysis, which one (out of VB 2005 and Visual C#) is better for my case.
It may be mentioned here that I am just beginner fo VB and absolutely no previous idea about C# or C++.
Indebted for your perpetual help
Lokman
AlanPosted Nov 3, 2007, 3:45 PM
I just tried the code, exactly as you had it in (1), and the four message boxes appeared one after the other before the application exited 'with code 0' when the End statement was reached. If I removed the 'End' statement, the form itself appeared and could then be closed in the normal way.
So I don't know what to make of it unless the project has somehow become corrupted or there's a problem with Visual Studio itself.
You could try creating a new VB Windows Forms project, paste in the code as before and then see whether you have better luck when you run it.
Incidentally, a bit of C# (the language I use most of the time) crept into my previous post with the curly brackets {} which aren't used in VB so ignore that :) The important thing is that you had the code in the Form1_Load method which should produce some results if everything is working OK.
Lokman HossainPosted Nov 3, 2007, 2:28 PM
Hi Alan,
1)
I appreciate your cooperation. Yes I double-click the form design mode and then come form1.vb mode where I put code exactly as follows: Also to inform you I did not drag any control button on the form design window.
Public
Class Form1 Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim anInteger As Integer = 42 Dim aSingle As Single = 39.345677653 Dim aString As String = "I like candy" Dim aBoolean As Boolean = TrueMsgBox(anInteger)
MsgBox(aSingle)
MsgBox(aString)
MsgBox(aBoolean)
End End SubEnd
Class2) Also I followed your suggestion, double click the form design mode and then put the code in between the { }. When I press F5 (debug), it gives me some error message....and did not get sny result. This probably because, when I first start the VS 2005, it asked me to choose the setting VB 2005, C#, Visul C++, Java, etc. I selected VB 2005. I MIGHT BE WORNG......TO SAY THIS REASON.
With regrads,
lokman
AlanPosted Nov 3, 2007, 1:51 PM
Well, there's nothing wrong with the code - I wouldn't normally use the End statement in a Windows Forms application but that doesn't matter when you're learning the language.
The problem may be where you've put it. If you haven't put any buttons or other controls on the form, then I'd put it in inside this method which opens up when you double click on the form when in design mode:
Private
Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load{
' put code in here
}
Lokman HossainPosted Nov 2, 2007, 10:16 PM
Hi Alan,
Thanks for your early cooperation. Yes, here is the code that I typed in on the window called "Form1.vb". And I start like this (open>new project>Windows application>Templates>OK)
Dim anInteger As Integer = 42
Dim aSingle As Single = 39.345677653
Dim aString As String = "I like candy"
Dim aBoolean As Boolean = True
MsgBox(anInteger)
MsgBox(aSingle)
MsgBox(aString)
MsgBox(aBoolean)
End
** By the way, I have a correction on my previous mail. It should be " No error are shown..." instead of "Now error are shown".
Thanks
Lokman
AlanPosted Nov 2, 2007, 3:48 PM