|
|
Visual Basic Names - Visual Basic Variabe Names | ||
Discussion by Athono with 11 Replies.
Last Update: January 1, 2007, 5:25 pm | |||
ResourceName
ResourceName$
ResourceName&
Mon Jan 9, 2006 Reply New Discussion
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 String
ResourceName& Dim ResourceName as Long
Special 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
# - Double
The MSDN Document
2.2.1 Type CharactersSee Also
Identifiers
A 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:
CODE
' The following line will cause an error: standard modules have no type.
Module Module1#
End Module
Module 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 Function
End Module
TypeCharacter ::=
IntegerTypeCharacter |
LongTypeCharacter |
DecimalTypeCharacter |
SingleTypeCharacter |
DoubleTypeCharacter |
StringTypeCharacter
IntegerTypeCharacter ::= %
LongTypeCharacter ::= &
DecimalTypeCharacter ::= @
SingleTypeCharacter ::= !
DoubleTypeCharacter ::= #
StringTypeCharacter ::= $
[note=jipman]
code-tags for code next time
[/note]
Wed Jan 11, 2006 Reply New Discussion
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.
Wed Jan 11, 2006 Reply New Discussion
Wed Jan 11, 2006 Reply New Discussion
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. :-)
Wed Jan 11, 2006 Reply New Discussion
Fri Feb 24, 2006 Reply New Discussion
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.
Sat Feb 25, 2006 Reply New Discussion
QUOTE (dhanesh)
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.
Link: view Post: 71124
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.
Fri Oct 13, 2006 Reply New Discussion
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.
Wed Oct 18, 2006 Reply New Discussion
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.
Mon Jan 1, 2007 Reply New Discussion
Mon Jan 1, 2007 Reply New Discussion
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
Mon Jan 1, 2007 Reply New Discussion
Finding The Current Line Number In A Text Box A very basic method of doing the deed. (1)
|
(3) Help On Inherit A Class In VB.NET ! Especially System.Net.Sockets.Socket
|
Index




