|
|
|
![]() |
|
|||||||
|
||||||||
![]() |
|
|
Thread Tools | Rate Thread | Display Modes |
|
|
|
#1
|
|||
|
|||
|
Visual Basic
I'm not exacly sure where to put this thread but....
Does anyone here program Visual Basic and have any tips. Microsoft Visual Basic 2005 Express is free and it's awesome. I've been developing for about half a year now. Also Coding4Fun (an msdn blog) is a great place to start. |
|
#2
|
|||
|
|||
|
Re: Visual Basic
Though I might not agree with all of what Microsoft does, they do bring new meaning to RTFM. One of the better benefits of the Visual Studio system is the help. Basically, if you want to do something, search the help, and more than likely there's already something in the .NET framework ready for you to use.
If you can learn to read the documentation that Microsoft provides and learn to implement what they give you, you should have a pleasant VB experience. However, VB has limitations...the professional CS types tend to use Java, C++ or C#, which give greater control over the processes. Java is platform independent, meaning it will run on a Mac, Linux, or Windows computer, provided it has the Java software (VM) from Sun. C++ allows you to program at low levels, even in assembly (think: controlling the processor step by step). C# is something of a blend. The syntax is c-style (as opposed to VB-style), but it is like VB with regard to the ease of use. That should give you a brief picture of what is going on. |
|
#3
|
|||||
|
|||||
|
Re: Visual Basic
i agree with the above, learning visual basic before any other languages should be avoided, it will teach you bad habbits that are hard to break when you move to a new language, such as c++
|
|
#4
|
||||
|
||||
|
Re: Visual Basic
I suggest that you familiarize yourself with the .net framework namespaces. It took me a while to get used to using the .net namespaces instead of the vb6 ones. Also, try playing around with the serial port class and your RC. I made a vb.net program that takes sensor data printf'd to the serial port graph on my laptop.
-Don |
|
#5
|
|||
|
|||
|
Re: Visual Basic
well, i agree with u guys somewhat but ive been programming visual basic for a year and love it! i have to admit running programs is a bit slow but, meh!
i also have a BasicX microcontroller which programs on visual basic and the BasicATOM programs with basic as well as for C and C++ i know the basics of (how can i be on a robotics team without at least knowing easyC) and im not screwed up by anything, i also know HTML, Javascript, CSS and im still not screwed up oh and by the way im sure a lot of you will agree but in c++ or sometimes C i hate those semicolons ;;;;;; ![]() |
|
#6
|
||||
|
||||
|
Re: Visual Basic
"It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration."
I'm not one to argue with Edsger Dijkstra. =) |
|
#7
|
|||
|
|||
|
Re: Visual Basic
Actually, those semi-colons are really useful in C/C++/C#. In all three cases, you can write several lines of neatly formatted code (a long string or calculation for instance) without needing to do an actual concatenation.
Also C/C++/C# allows for "fall through" switch/case statements. which are valuable. Conditional statements are also more concise, since C/C++/C# all interpret the value 0 for byte, int, long , etc as a false bool. This, along with the ?: operator in C# allows for this: int i = 0; string str = (!i) ? "Is Zero" : "Is Not Zero"; which would look like this in VB: Dim i as Integer Dim str as String i = 0 If(i == 0) str = "Is Zero"Else str = "Is Not Zero"End As you can see, the C# code is much more concise than the VB code. Also, you may love doing VB for now, when it's all for play, glitz, and glam. However, if you pursue CS or EE as a profession later on, you will quickly learn that VB is "programming for business majors." (i.e. there is no rigor to it) Real (professional) programmers and engineers pay a great deal of attention to data structure, argument passing, type casting, etc...all of which VB is very loose with. |
|
#8
|
|||||
|
|||||
|
Re: Visual Basic
Heh, it's just a problem of insufficient hardware
Quote:
That being said, if you can teach yourself (or get taught) regular old C, you'll have a foundation that will pay you well for the rest of your life. Not a bad return for a High School student... Don |
|
#9
|
||||
|
||||
|
Re: Visual Basic
Quote:
Quote:
Code:
'VB.net code'
Dim i As Integer = 10
Select Case i
Case 1
DoSomething()
Case 10
DoSomethingElse()
End Select
Code:
Option Explicit On Option Strict On Quote:
--------- I know some people will say I'm insane, or stupid, but I'll say this anyways. I am equally capible of proramming in C# and VB.net. I also have some experiance with C++ on windows, and C on the RC, but .net is what I really have experiance with. Now, this is what some people won't believe. I am more effecient in VB! The background compilation, LINQ to XML(in vs2008 Beta 2), case-insensitivity, ect., make me much more productive than C#. EDIT: As languages I have no preference between VB and C#, but the IDE features of VB.net are far superior of C#. Just my opinion. Tips for people interested in .net. Read these blogs: Coding Horror Coding4Fun Listen to these podcasts: .Net Rocks! HanselMinutes Use these sites: CodeProject Last edited by EHaskins : 13-11-2007 at 23:21. |
|
#10
|
|||
|
|||
|
Re: Visual Basic
Yes, that's a switch-case statement. However, a fall-through switch case statement is a little different:
int i,x,y,z; switch(i) { case(1): x = 4; case(2): y = 4; case(3): z = 4; break; default: x = y = z = 0; break; } This code sets: x,y,z to 4 if i = 1 y, z to 4 if i = 2 z to 4 if i = 3 x, y, z to 0 else It's called "fall through" because there are no break statements in the early set of cases. This means that the case i == 1 falls through to i == 2 which in turn falls through to i == 3. There are many situations where this is useful, especially if the cases for i are not mutually exclusive. From my understanding of VB, the above block would have to be coded this way: Select(i) case(1): x = 4 y = 4 z = 4 case(2): y = 4 z = 4 case(3): z = 4 default: x = 0 y = 0 z = 0 End Select I might be wrong about that VB switch statement, but I'm pretty sure it doesn't support the fall-through idea. de KG2OV |
|
#11
|
||||
|
||||
|
Re: Visual Basic
Quote:
However, after reading your post i decided to try that in C#, and as far as I can tell C# dosn't support that either. This code: Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int i = 10;
switch (i) {
case (1):
Debug.Print("1");
case (2):
Debug.Print("2");
}
}
}
}
Error 1 Control cannot fall through from one case label ('case 1:') to another C:\Users\Eric Haskins\Documents\Visual Studio 2008\Projects\ConsoleApplication1\ConsoleApplicati on1\Program.cs 15 17 ConsoleApplication1 Error 2 Control cannot fall through from one case label ('case 2:') to another C:\Users\Eric Haskins\Documents\Visual Studio 2008\Projects\ConsoleApplication1\ConsoleApplicati on1\Program.cs 17 17 ConsoleApplication1 Am I being stupid again, or is this a limitation of all .net languages? EDIT: I found my own answer. http://msdn2.microsoft.com/en-us/lib...28(VS.90).aspx That seems slightly old VBish. EDIT: More info http://blogs.msdn.com/abhinaba/archi...15/492866.aspx -Eric Last edited by EHaskins : 13-11-2007 at 23:18. |
|
#12
|
|||
|
|||
|
Re: Visual Basic
I really meant my fall through explanation to be focused on C/C++. Frankly, I have never used it in a C# application, but I assumed the C-style syntax would support it...I was apparently wrong.
So, let's apply my previous post to C/C++ only. Also, the link you posted is a good work around for a fall through. However, as a practice, GOTO statements violate OOP principals, and I try to avoid them at all costs. P.S....I've been itching for a correlary to __asm (from C++) in C#. Perrhaps __cpp, or __C++, or __cplusplus to allow for inline C++ code in C#. I suppose I'll never see it. |
![]() |
| Thread Tools | |
| Display Modes | Rate This Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Visual Basic help needed. | Cody Carey | Programming | 1 | 25-02-2007 15:06 |
| Visual Basic Scouting Problem | Jeffel | Programming | 7 | 11-02-2005 19:30 |
| Visual Basic | dddriveman | Programming | 12 | 20-03-2004 13:03 |
| Visual Basic 6 Dashboard | LBK Rules | Programming | 1 | 22-01-2003 13:06 |