Tilted Forum Project Discussion Community  

Go Back   Tilted Forum Project Discussion Community > Interests > Tilted Technology


 
 
LinkBack Thread Tools
Old 02-12-2005, 12:49 PM   #1 (permalink)
Insane
 
yatzr's Avatar
 
[VisualBasic] A few questions on commands

I know java pretty well and am now learning Visual Basic and I'm having some problems.

First, what is the Visual Basic equivalent to Java's try-catch error resolving? I can't find this anywhere in my VB book. Does Basic have something similar?

Second, Is there a command to see if a file exists?

Thanks
__________________
Mechanical Engineers build weapons. Civil Engineers build targets.
yatzr is offline  
Old 02-12-2005, 01:11 PM   #2 (permalink)
Junkie
 
Stiltzkin's Avatar
 
I think starting with Visual Basic.NET, you can use:

Try (arguments)

Catch

End Try
__________________
The most important thing in this world is love.
Stiltzkin is offline  
Old 02-12-2005, 03:24 PM   #3 (permalink)
Insane
 
yatzr's Avatar
 
well, i'm not using the .net version...VB6 doesn't have that but I found it anway.
I do have another question now though.

Can someone explain the structure of a class and relate it to a typical java class? I understand java classes pretty good but I'm pretty lost on VB classes (at least with the variables and properties...I don't understand what those are). Also, with methods, how do I "return" a value?
__________________
Mechanical Engineers build weapons. Civil Engineers build targets.
yatzr is offline  
Old 02-14-2005, 06:30 AM   #4 (permalink)
Muffled
 
Kadath's Avatar
 
Location: Camazotz
Quote:
Originally Posted by yatzr
well, i'm not using the .net version...VB6 doesn't have that but I found it anway.
I do have another question now though.

Can someone explain the structure of a class and relate it to a typical java class? I understand java classes pretty good but I'm pretty lost on VB classes (at least with the variables and properties...I don't understand what those are). Also, with methods, how do I "return" a value?
I am not spectacular with VB, but instead of returning, you can pass a variable ByRef instead of byVal and the actual variable is changed. So if you declare the variable in the main, then run a module with the variable passed as an argument ByRef and when you finish the module the variable itself will have changed.
__________________
it's quiet in here
Kadath is offline  
Old 02-14-2005, 06:47 AM   #5 (permalink)
zen_tom
Guest
 
A VB Class is not a whole lot different to a Java class. It needs to be defined within a class module, and is simply a collection of hidden variables that are accessed via 'Property Let' and 'Property Get' statements - So, say I want to create a class that represents a Cartesian Coordinate called CartCoord, I'd create a class module Called CartCoord and fill it with the following:

Code:
Private privX as Double
Private privY as Double

Property Let X (aValue as Double) 
privX = aValue
End Property

Property Get X () as Double
X = privX
End Property

Property Let Y (aValue as Double) 
privY = aValue
End Property

Property Get Y () as Double
Y = privY
End Property

Property Get DistanceFromOrigin() as Double
DistanceFromOrigin = Sqr(PrivX^2 + PrivY^2)
End Function
So after creating an instance of the object, I can populate the X and Y values, and then ask it to tell me the distance the represented point is from the Origin like so:

Code:
Set MyPoint = New CartCoord
MyPoint.X = 3
MyPoint.Y = 4
Z = MyPoint.DistanceFromOrigin
So later, when I query Z (assuming I remember my trigonometry right), I should have a value of 5.

Last edited by zen_tom; 02-14-2005 at 06:49 AM..
 
 

Tags
commands, questions, visualbasic


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 12:15 PM.

Tilted Forum Project

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73