Athono 0 Report post Posted January 9, 2006 In Visual Basic, what is the difference between:ResourceNameResourceName$ResourceName& Share this post Link to post Share on other sites
tansqrx 0 Report post Posted January 11, 2006 ohhh, ohh, ohh, pick me, pick me (jumps up and down with hand raised)I actually had to look this one up because at first I thought they were all completely valid and done the same thing. After typing the variable name in Visual Studio I quickly had to turn to the help. I started in .NET and as such I am mostly ignorant of VB6 which this crap almost certainly came from. My example is for .NET.In short,ResourceName valid variable name although it will not compile because no type is given (string, integer, etc.)ResourceName$ Dim ResourceName as StringResourceName& Dim ResourceName as LongSpecial characters are short hand for assigning a type to a variable name. I have seen this used in older VB6 code but I would never use such bad techniques myself. Other types include:% - Integer@ - Decimal! â Single# - DoubleThe MSDN Document2.2.1 Type CharactersSee AlsoIdentifiersA type character following a non-escaped identifier denotes the type of the identifier. The type character is not considered part of the identifier. If a declaration includes a type character, the type character must agree with the type specified in the declaration itself; otherwise a compile-time error occurs. If the declaration omits the type, the type character is implicitly substituted as the type of the declaration.No white space may come between an identifier and its type character. There are no type characters for Byte or Short.Appending a type character to an identifier that conceptually does not have a type (for example, a namespace name) will cause a compile-time error. The following example shows the use of type characters: ' The following line will cause an error: standard modules have no type.Module Module1#End ModuleModule Module2 ' This function takes a Long parameter and returns a String. Function StringFunc$(ByVal LongParam&) ' The following line causes an error because the type' character conflicts with the declared type of' StringFunc and LongParam. StringFunc# = CStr(LongParam@) ' The following line is valid. StringFunc$ = CStr(LongParam&) End FunctionEnd Module TypeCharacter ::= IntegerTypeCharacter | LongTypeCharacter | DecimalTypeCharacter | SingleTypeCharacter | DoubleTypeCharacter | StringTypeCharacterIntegerTypeCharacter ::= %LongTypeCharacter ::= &DecimalTypeCharacter ::= @SingleTypeCharacter ::= !DoubleTypeCharacter ::= #StringTypeCharacter ::= $ Notice from jipman: code-tags for code next time Share this post Link to post Share on other sites
Khymnon 0 Report post Posted January 11, 2006 Well, type-characters used to be very nice short-hands before Visual Basic 5. Some old-timers love it and will debate who says otherwise relentlessly :-).But I suppose you're when you say it's bad; but it's not bad technique, merely bad coding style. At least, I think so. Share this post Link to post Share on other sites
tansqrx 0 Report post Posted January 11, 2006 OK I will agree with that, just bad coding style. I have just found out that bad coding style can sink a ship quicker than almost anythign else. Share this post Link to post Share on other sites
Khymnon 0 Report post Posted January 11, 2006 Totally true, transgrx. :-)Although proper coding styles were a merely means of convenience and maintenance in earlier versions, new features like inheritance, up- and down-casting, polymorphism and the like make it essential to adopt a consistent *correct* style, effectively deminishing the fine line between style and proper syntax.Actually, I come from a low-level programming background (e.g. C, C++) so I think by now I instinctively force myself to more strict coding styles even if the alternative can do the job well. :-) Share this post Link to post Share on other sites
nopaniers 0 Report post Posted February 24, 2006 I agree absolutely. These short cuts are there because of backwards compatability. Don't use them if you can possibly avoid it. Something like 80% of software cost is on maintanance so it's worth your time to be clear about the type of a variable... Share this post Link to post Share on other sites
dhanesh1405241511 0 Report post Posted February 25, 2006 Dont Kick my nuts if i am being too VB illiterate .. I just started learning VB as a course in university .. Please explain in detail for the above, ResourceName$ Dim ResourceName as String and ResourceName& Dim ResourceName as Long Normally we were told to define a variable like Dim a As Integer , here a being the variable. Where does this ResourceName$ Dim ResourceName come in ? Just a little Inquisitive Regards Dhanesh. Share this post Link to post Share on other sites
Lee-Programmer 0 Report post Posted October 13, 2006 Dont Kick my nuts if i am being too VB illiterate .. I just started learning VB as a course in university .. Please explain in detail for the above, ResourceName$ Dim ResourceName as String and ResourceName& Dim ResourceName as Long Normally we were told to define a variable like Dim a As Integer , here a being the variable. Where does this ResourceName$ Dim ResourceName come in ? Just a little Inquisitive Regards Dhanesh. I'm not really trying to tease you here, but that is VB.NET. It has quite some difference to VB6. Doing this in VB6 will cause an error. That's why, trust your instincts, unless you do not feel the passion of programming (Purrr). Form what I could gather, it only exist in VB.NET. PS: VB.NET is a language for computer servers, hardly useful in a normal program. Share this post Link to post Share on other sites
tansqrx 0 Report post Posted October 18, 2006 I have to somewhat disagree with your observations that VB.NET is only a server language. I have written many standalone Windows Forms applications. The current program is 10K+ SLOC and I have had no problems with VB.NET yet (in the sense of being a poor programming language). With the advent of the .NET Framework, VB.NET is just as powerful and has 99.9% of the features as C#. It is true that the majority of uses of VB.NET have been with ASP and database applications but I don’t think this is because it is a “server” language.I guess the bottom line is this. The choice between VB.NET and C# is only what you are used to program in. If you came from C++ then C# is naturally your choice, if coming from VB then you will feel quite at home with VB.NET. Share this post Link to post Share on other sites
Lee-Programmer 0 Report post Posted January 1, 2007 You may be right about this, but look at the main features of the two similar but different programming languages.Visual Basic .NET's major advantage is that it has .asp (active server pages) and SQL and built in xml tools. But, it does not do that well with other aspects of programming such as OpenGL and Direct X. It aslo involves with a lot of web controls, giving the hint that it is meant for servers.Visual Basic 6 has a better capability over things such as graphic manipulation fares better, creating .ocx and .dll and slightly better in API (but not as good in C/C++). As you can see, these things are all local resource programs. Visual Basic 6's internet connection tools are really, bad. The only way it can comunicate is to use a plugin written in some other language, or with API, which is not that great.And additionally, .NET has this capability of a Client to Server capability included, which was why I said server language (althogh i meant server-client). I have used .NET before, don't think amade random assumtions.PS: Even if I use GNU C++, I do not really like Microsoft C#. It is just a lousy effort by Microsoft to monoplise the programming language (note that is why we don't get compilers for such programs (such as C# and VB) from non-Microsoft based companies). C++ and Java are open languages, like html, anybody could make compilers for them if they want. Share this post Link to post Share on other sites
tansqrx 0 Report post Posted January 1, 2007 Just as an added comment to your P.S., you should look at the MONO Project at /. Share this post Link to post Share on other sites
turbopowerdmaxsteel 0 Report post Posted January 1, 2007 I know we are getting a bit off topic, but...No matter what you call Microsoft's putting together of the trademark Visual Studio members, you can't deny that they have pioneered many new technologies. Let me state some pertaining to the revolutionary Visual Basic.VB6 is undisputedly the world's most popular language.> The name visual itself is very important, for the first time, people could drag and drop controls onto a design surface and see how a program would look without going through the lengthy edit-compile-test cycles required by other languages.> Stepping through code while debugging - just ask any VB developer if they could do without it.> The introduction of Active X Controls took the idea of code reusability to a completely new level. > VB was also the first popular general-purpose language to offer truly integrated database access.> The IDE concept that VB revolutionized has now been incorporated by non Microsoft products too (Delphi, Java).> Intellisense - It speeds up software development by reducing the amount of keyboard input required and allows less reference to external documentation due to embedded function signatures and short descriptions.True it lacked the pure object oriented power of other languages, but hasn't it caught up with .NET? As we programmers grow lazier day by day , changes such as these are greatly welcome and with the further advent of hi-tech sidekicks, we will do so even more. Share this post Link to post Share on other sites