PDA

View Full Version : Visual Basic SUCKS



mdklatt
3/6/2006, 02:16 PM
No intrinsic function to find the size of an array--are you kidding me??

Edit: The functions they do give you (UBound and LBound) don't work on unallocated arrays, and there doesn't seem to be a way to determine if an array has been allocated yet short of using your own boolean variables. :mad:

crawfish
3/6/2006, 02:17 PM
http://www.organissimo.org/forum/uploads/post-14-1101485037.jpg

Nab'R
3/6/2006, 02:44 PM
10 cls
20 a$="COOL!"
30 b$="Gnarly!"
40 z=rnd(20)
50 if z/2=int(z/2) print a$ else print b$
60 end

jkm, the stolen pifwafwi
3/6/2006, 02:48 PM
array or arraylist?

mdklatt
3/6/2006, 02:50 PM
array or arraylist?

Array, I guess--I've never heard of an ArrayList, and the paper clip doesn't know what I mean and would like me to rephrase the question.

jkm, the stolen pifwafwi
3/6/2006, 02:52 PM
i guess my first question should be "what version of VB are you using?"

mdklatt
3/6/2006, 02:53 PM
i guess my first question should be "what version of VB are you using?"

VBA for Office 2000

Norm In Norman
3/6/2006, 03:06 PM
No intrinsic function to find the size of an array--are you kidding me??

Edit: The functions they do give you (UBound and LBound) don't work on unallocated arrays, and there doesn't seem to be a way to determine if an array has been allocated yet short of using your own boolean variables. :mad:

Public Function IsDimensioned(pstrArray() As String) As Boolean
On Error GoTo vbError
Dim i As Integer

i = LBound(pstrArray)
IsDimensioned = True

vbError:
End Function

mdklatt
3/6/2006, 03:10 PM
Public Function IsDimensioned(pstrArray() As String) As Boolean
On Error GoTo vbError
Dim i As Integer

i = LBound(pstrArray)
IsDimensioned = True

vbError:
End Function

I guess that'll do the trick. Thanks.

Norm In Norman
3/6/2006, 03:17 PM
That's a pretty standard VB function. I'm a VB Monkey, so I'd know. Only problem is you have to write one for every type. It seems like you could use a variant instead of writing that function for each type, so I can't remember why I didn't do it that way. Maybe I just refused to write it because variants are stupid. Probably it doesn't work in some instance or something.

Norm In Norman
3/6/2006, 03:19 PM
Oh, and for the stuff I use VB for, I'll take it over Java any day of the week. We only use it for simple stuff though. And I use API calls for almost everything. I hate controls.

mdklatt
3/6/2006, 06:24 PM
Is there a way to declare and initialize a variable in one statement? So I don't have a bunch of stuff like this cluttering things up?



Dim timestamp as String
timestamp = data(i, 1)

Vaevictis
3/6/2006, 07:01 PM
It is practically impossible to teach good programming style to students that [sic] have had prior expose to BASIC; as potential programmers they are mentally mutilated beyond hope of regeneration.


... and Visual Basic is worse.

starclassic tama
3/6/2006, 07:51 PM
nerds

Stoop Dawg
3/6/2006, 08:36 PM
Is there a way to declare and initialize a variable in one statement? So I don't have a bunch of stuff like this cluttering things up?



Dim timestamp as String
timestamp = data(i, 1)


It's VB, why even declare it? ;)

Vaevictis
3/6/2006, 08:59 PM
nerds

That's MISTER NERD to you!

mdklatt
3/6/2006, 11:04 PM
It's VB, why even declare it? ;)

I just wonder why VB seems to discourage the programmer from declaring variables. How hard is it to included initialization in the declaration? Even PHP can manage that. And why does a freaking scripted language disallow run-time constants?

sanantoniosooner
3/6/2006, 11:09 PM
Brokeback threads>
religious threads>
political threads>
buttzit threads>
computer geek threads

:D

mdklatt
3/6/2006, 11:10 PM
In VBA for Office is there anything similar to an Excel.Range? I'd like to return an arbitrary bunch of cells from a function, but AFAICT a Range only refers to a physical location on a Worksheet.

RacerX
3/7/2006, 12:06 AM
Array, I guess--I've never heard of an ArrayList, and the paper clip doesn't know what I mean and would like me to rephrase the question.

You should use the dog. The dog is smarter.

GrapevineSooner
3/7/2006, 12:19 AM
Funny thing is I'm thinking of clearing out some book space on my desk and I just happened to look down at this huge and beat up book that I used for college and thought 'Gee, I guess I'll never use VisualBasic anymore. I'll just toss this book in the trash.'

:D

Norm In Norman
3/7/2006, 09:10 AM
Is there a way to declare and initialize a variable in one statement? So I don't have a bunch of stuff like this cluttering things up?



Dim timestamp as String
timestamp = data(i, 1)

I don't think so.

While I've been doing php for a while now and like it a lot better, I still like VB. I can whip up a program way faster than the java guys here can. I wouldn't use it for a big system though, but it has it's uses.

Right now I'm messing with some bash scripts on a 'nix machine and I wish I had VB to use instead.

Getem
3/7/2006, 09:43 AM
I don't think so.

While I've been doing php for a while now and like it a lot better, I still like VB. I can whip up a program way faster than the java guys here can. I wouldn't use it for a big system though, but it has it's uses.

Right now I'm messing with some bash scripts on a 'nix machine and I wish I had VB to use instead.

why not use php from the command line?

Getem
3/7/2006, 09:44 AM
I just realized looking at my avatar here at work that MS STILL has not fixed transparent PNG in IE!

mdklatt
3/7/2006, 10:10 AM
You should use the dog. The dog is smarter.

Actually I use the cat, which is probably smarter than the dog.

Norm In Norman
3/7/2006, 10:57 AM
why not use php from the command line?
HAH!

Well, we are using a version of PHP that is pre-command line (4.0.16). I want to upgrade to the latest, but unfortunately we have code that will no longer work if we upgrade. Since my group is supposed to have 7 people and there are only 2 of us left, I don't have enough time to fix all of the code that won't work after the upgrade. And really, the code that doesn't work should be completely rewritten anyway (because it's HORRIBLE code), which will take even longer.

Ironically, if we upgraded to 5 we'd have more functionality that would make coding easier and would save me time - enough time to upgrade the old code. And I could belt out the scripts in php that I've spent days learning bash scripting for in a couple of hours. Catch 22.

Double ironically, I'm posting on here. Catch 23.

jkm, the stolen pifwafwi
3/7/2006, 11:43 AM
in vb.net, it would be

dim str as string = data(a, i)

and yes, option explicit is on by default.

i think the bigger issue is that you are using software that is 2/3 of a decade old ;)

sanantoniosooner
3/7/2006, 11:46 AM
I'm not sure who this 'mdklatt' is, but it's obvious he's hooked a lot of fish with this thread.

mdklatt
3/7/2006, 11:52 AM
i think the bigger issue is that you are using software that is 2/3 of a decade old ;)

The BIGGER issue, then, is why did it take so long for VB to start doing something that other programming languages have been doing for 20-30 years? ;)

jkm, the stolen pifwafwi
3/7/2006, 11:54 AM
The BIGGER issue, then, is why did it take so long for VB to start doing something that other programming languages have been doing for 20-30 years? ;)

if you worked here, you'd be shocked they even got that far

mdklatt
3/7/2006, 12:47 PM
if you worked here, you'd be shocked they even got that far

:D

Vaevictis
3/7/2006, 01:26 PM
Right now I'm messing with some bash scripts on a 'nix machine and I wish I had VB to use instead.

Perl is ever so much yummier, so long as you don't mind the whole write-only behavior.

mdklatt
3/7/2006, 01:29 PM
Perl is ever so much yummier, so long as you don't mind the whole write-only behavior.

Perl is the debil.

Norm In Norman
3/7/2006, 01:32 PM
I figured I could pull the bash scripts off easier without learning a bunch of extra stuff like I would have to in perl. Of course that was before I spent 2 hours debugging a script only to find that the error was that I LEFT A SPACE OUT OF AN IF STATEMENT.

sooner_born_1960
3/7/2006, 01:41 PM
ifsomething = 5
then
something := 6;
end if;

The space looks pretty important to me.

Vaevictis
3/7/2006, 01:48 PM
If you are likely to spend any time at all in a UNIX environment doing system administration, bite the bullet and learn perl. What VB is intended to do for Windows (rapidly write throw-away applications), perl does for UNIX.

And yes, perl is the Devil, but even the Devil has his uses.

sanantoniosooner
3/7/2006, 01:53 PM
If there's one thing I've learned from this thread............

You CANNOT derail a geek thread, unless you are a geek doing so in geek fashion.

Dude........there are 8 bits in a byte...........

Vaevictis
3/7/2006, 01:55 PM
Perl is the debil.

s/debil/AWESOME/

Fixed it for you. ;)

Norm In Norman
3/7/2006, 02:08 PM
ifsomething = 5
then
something := 6;
end if;

The space looks pretty important to me.
No, it was more like this:


if ["$return_val" -gt "0"]; then

that gave me an error. Sadly, I didn't learn anything from it because I don't exactly remember the problem past it had to do with spaces.

AND WHO THE HELL USES "-gt" AS ">" IN THEIR PROGRAMMING LANGUAGE? OK, scripting language. but still..

NormanPride
3/7/2006, 02:19 PM
pl/sql for the win, y0.

skycat
3/7/2006, 02:21 PM
s/debil/AWESOME/

Fixed it for you. ;)

I do love me some perl.

Vaevictis
3/7/2006, 02:40 PM
pl/sql for the win, y0.

That's just a wee-bit heavyweight for casual system administration. IMHO, of course ;)

Stoop Dawg
3/7/2006, 02:53 PM
AND WHO THE HELL USES "-gt" AS ">" IN THEIR PROGRAMMING LANGUAGE? OK, scripting language. but still..

People who have already defined ">" to be an output pipe?

An internet message board full of software geeks - whodda thunk it?

Stoop Dawg
3/7/2006, 02:53 PM
And yes, I include myself in there.

Stoop Dawg
3/7/2006, 02:54 PM
And I always thought ksh was better than bash, but I never used bash so what do I know? Nothing, that's what.

Vaevictis
3/7/2006, 03:00 PM
Dude, if you're not using "sh" and "ed", you need to turn in your geek badge, cause it's a fake. Pfft, using bash and ksh. What a bunch of n00blets.

Unless you're doing input by levers and buttons, and output via LED or true teletype only. There's an exception clause for those.

NormanPride
3/7/2006, 03:01 PM
That's just a wee-bit heavyweight for casual system administration. IMHO, of course ;)

Psh. Pansy. Just be glad you don't have to use JCL.

Vaevictis
3/7/2006, 03:04 PM
Psh. Pansy. Just be glad you don't have to use JCL.

You ever had the opportunity to shuffle somebody's punch cards? There is no joy in life quite so joyfull as that. Especially if you've got your BOFH hat on. "Sorry, job didn't run right."

(I'm not old enough to have been on the BOFH side of that, but as a kid, my mother took me into the computer lab with her, and yes, I did shuffle some stacks. :) )

Norm In Norman
3/7/2006, 03:16 PM
People who have already defined ">" to be an output pipe?

An internet message board full of software geeks - whodda thunk it?
They could have made " > " be greater than and ">" be the output pipe. It seems like they've done that in other cases.

And damned if there isn't an "-eq" AND an "=". Like I can keep that straight.

Vaevictis
3/7/2006, 03:19 PM
I think the lesson here is that you shouldn't use shell scripting unless you absolutely have to. (I learned that lesson c.1995 when I first slapped linux on the 486sx ;) )

(which is not to say don't use the stuff interactively, but perl is sooo much better if what you need to do involves writing an actual program)

Norm In Norman
3/7/2006, 03:24 PM
Well, let's say my script doesn't do hardly anything, where I was really wanting a bunch of error checking, email, logging, and stuff like that. I'll probably end up re-writing it in perl to add functionality.

mdklatt
3/8/2006, 07:48 PM
Dim input_range as Range
input_range = Worksheets.Item("Sheet1").Range("A2:B10")




Run-time error: '91'

Object variable or With block variable not set


:confused:

And why the can't can't you copy the text in an error dialog box? :mad:


EDIT:

I just realized you have to use Set with object variables--but not regular variables. Sweet jesus. :mad:

Microsoft, why do you hate consistency? :mad: :mad:

mdklatt
3/16/2006, 07:43 PM
Is there a simple way to set an Excel.Range object as the second cell to the second to the last cell in the first column? i.e. Cells(2, 1) -> Cells(X, 1)

Norm In Norman
3/17/2006, 09:49 AM
Speaking of Visual Basic sucking...

I wrote a report class a while back (4 or 5 years ago) and used it in a pretty important project I finished about a year ago. In this report class, I pass it recordset, some header and layout info, and boom out comes the report (to the printer or in a print preview). I always thought the simplicity of my class was pretty cool and the reports always come out looking quite good. The interface maybe wasn't great, but it worked and I'm a programmer so what do I care?

Unfortunately, I decided to use a picture box for each page in the report and print the report out on that. Evidently, there is a limitation of gdi that a VB monkey like myself wouldn't know about: it uses a fairly limited amount of memory. So after about 40 pages of one of my reports, it runs out of memory and crashes my program. Now normally the reports don't get much more than 10 pages, but a year after they've been using my program they've found an instance where the report will be about 50 pages. So now I have to rewrite the report class.

It seems obvious to me now that I should have created pdfs. In fact, about 2 years ago I remember thinking "Damn, i should have written these as pdfs, but it's too late now." Well, i guess it wasn't too late because that's how I'm going to fix it. It's going to mean a complete rewrite of my class.

Anyway, this just reminds me of how when you program in VB you are ALWAYS having to figure out workarounds for limitations of the language. You can really throw apps together fast though...

Veritas
3/17/2006, 10:01 AM
Oh it makes me happy to see a thread on here about the barftaculous nature of VB.

The B stands for "Beginners." I'm not sure why MS kept it on life support in their .NET paradigm, as C# is such a no brainer that it obviates the need for VB.

Of course, I'm bitter about VB (and Basic in general) having had to spend too many hours of my life parsing through someone else's horrid implementation in order to recreate their work in a proper manner.


VB Victor

Sometime in the nineties Victor underwent what is colloquially referred to as a "Visual Basic Lobotomy". He found himself a programmer on a misconceived and overly ambitious VB project, and fought to write a serious enterprise application for some years in a language that was never conceived for more than small scale usage. Visual Basic Land is a warm and soothing place, and Victor let his skill set atrophy while he slaved away at VB, until eventually VB was all he was good for. Now, dispirited and deskilled, he is a testament to the hazards of building your career upon a narrow technological basis. Victor will likely survive a few more years, pottering from one VB project to the next, until he loses the enthusiasm even for that.

http://www.hacknot.info/hacknot/action/showEntry?eid=81

(I'm C++ Colin. :O)

mdklatt
3/17/2006, 10:28 AM
Is there a simple way to set an Excel.Range object as the second cell to the second to the last cell in the first column? i.e. Cells(2, 1) -> Cells(X, 1)

So...no?

Norm In Norman
3/17/2006, 10:35 AM
VB Victor

Sometime in the nineties Victor underwent what is colloquially referred to as a "Visual Basic Lobotomy". He found himself a programmer on a misconceived and overly ambitious VB project, and fought to write a serious enterprise application for some years in a language that was never conceived for more than small scale usage. Visual Basic Land is a warm and soothing place, and Victor let his skill set atrophy while he slaved away at VB, until eventually VB was all he was good for. Now, dispirited and deskilled, he is a testament to the hazards of building your career upon a narrow technological basis. Victor will likely survive a few more years, pottering from one VB project to the next, until he loses the enthusiasm even for that.
NOOOOOOOOOOOOOOOOOOOOOOOO!!!!!!!!!

php will save me.

mdklatt
3/17/2006, 10:36 AM
php will save me.

Don't get me started on PHP....

Norm In Norman
3/17/2006, 10:40 AM
NOOOOOOOOOOOOOOOOO!!!!!


I am NOT going to program in Java just because society tells me I have to.

mdklatt
3/17/2006, 10:49 AM
NOOOOOOOOOOOOOOOOO!!!!!


I am NOT going to program in Java just because society tells me I have to.


C++ is how I usually roll. Fortunately I'm my own project manager and developer so I'm free to choose the best tool for the job. I've never needed to use Java, thank goodness. PHP is nice for dynamic web pages, but if you have to do something serious on those web pages it starts to bog down. What I've been trying to do in VBA the last couple of weeks could have easily been done in a day in C++ or Fortran, but this is at least in part due to my unfamiliarity with VBA. However, the more I learn about it, the less I like it. Bleh.

Norm In Norman
3/17/2006, 11:02 AM
Well yeah, you aren't going to do any heavy processing with php. That's why it gets used in conjunction with other stuff. Right now php is quite popular though and may be my only way out.

I knew I should have pushed for .Net when I had the chance. Good old lazy norm.

mdklatt
3/17/2006, 12:18 PM
I think I have a new strategy for VBA: Forget trying to make something efficient, extensible, and maintainable and just hack something together. Since that's how VB came into being in the first place, why fight the inevitable?

jkm, the stolen pifwafwi
3/17/2006, 12:19 PM
i am so skill set sam...

skycat
3/17/2006, 12:25 PM
I think I have a new strategy for VBA: Forget trying to make something efficient, extensible, and maintainable and just hack something together. Since that's how VB came into being in the first place, why fight the inevitable?

Whatever code I do write, is written exactly like this.

It's probably a good thing that I don't have to write much code.

mdklatt
3/17/2006, 12:42 PM
I have definite Generic George tendencies. :O

Veritas
3/17/2006, 01:34 PM
I have definite Generic George tendencies. :O
Oh, I fight that one too. My business partner jokes that "extensible" is my favorite word.

I tell him to STFU and go get us anther client already, since nobody complains about our deployment times.

mdklatt
3/23/2006, 07:33 PM
So I've turned my VB stuff into an Excel Add-in (XLA) and loaded it. Now what? How do I access the macros?

Stoop Dawg
3/23/2006, 08:35 PM
I have definite Generic George tendencies. :O

Design for tomorrow. Code for today.