Page 1 of 1

Capabilities of VB in HB scripts?

Posted: Sun Mar 06, 2005 10:02 am
by loo_hoo_ser
Hi all -



I'm just learning how to use Visual Basic (VB) for use in Housebot scripts. At first, I thought the scripting language was rudimentary but after I started learning VB, there are a lot of real neat things you can do with HB scripts. I learned the language by using the Microsoft Excel's VB langauge reference - it's available as part of Excel's help resource. I found it very handy because it lists all the statements, functions, and keywords that can be used in VB. More importantly, code examples are provided.



However, I do have a question about the VB capabilities in HB. Is it a full VB implementation? Although the Excel version has some spreadsheet specific functions meant for manipulating its worksheets, I stayed away from those. However, I had trouble with some of the VB capabilites that it was supposed to have. For example, I tried to declare an array of strings by using the statement:


Code: Select all

dim arrayOfStrings as array of string


I'm just typing this from memory so I may not have the syntax correct, but I did take a code example and HB refused to allow anything after the variable name, saying it was expecting an end of line. I was not able to explictly declare variables as integers, either.



The other thing I had trouble with was a For...Loop. On the face of it, it looks really simple. Howver, HB refused to let me implement a for...loop of any kind and I ended up using a Do...While loop construct instead.



So that made me wonder if I can actually use all the VB capabilities or are only a subset available for use? If so, where can I find more information on its actual capabilities?



Thanks.

Posted: Sun Mar 06, 2005 10:25 am
by paran0id
I'm no vb-guru but it should look like this:

Code: Select all

dim arrayOfStrings as array
(If I'm not completely mistaken)

And it should not look like this:

Code: Select all

dim arrayOfStrings as array of string


Visual Studio 2003.NET doesn't like the latter so I

don't think vb-scripts would like it either



Cheers

/p

Posted: Sun Mar 06, 2005 10:28 am
by dlmorgan999
HouseBot supports VBScript. This is a subset of VBA (Visual Basic for Applications) which is what Excel supports. VBA is a subset of full Visual Basic. Here is a site with a lot of good info on VBScript:



You can't specify the type for VBScript variables (they are all Variant). But VBScript does support arrays.



Here is another site with a good introduction to variable use in VBScript (including information about using arrays).



-- Dave

Posted: Sun Mar 06, 2005 11:12 am
by loo_hoo_ser
Thanks for the responses!



Let me get this straight... Visual Basic is the full set. Visual Basic for Applications (which Excel has) is a subset of VB. Visual Basic for Scripting is a subset of VBA? I'll check out the references provided in this thread.



How does one work with time and dates in VBscript? If I obtain the value of a property in HB via getProperty that is a time or date. I believe that these kind of property values (date/time) are returned as strings. How do I test them (perform evaluations with another date such earlier or later than another date) in VB script?

Posted: Sun Mar 06, 2005 11:45 am
by dlmorgan999
Let me get this straight... Visual Basic is the full set. Visual Basic for Applications (which Excel has) is a subset of VB. Visual Basic for Scripting is a subset of VBA? I'll check out the references provided in this thread.
Yes, all of the above statements are correct although to be more precise, the VBA versions have a number of additional commands that are specific to the application (Excel, Word, etc.).



To do date operations, you can use the CDate function. Also check out DateDiff and some of the other date-related functions on this page.