Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
vbScript - the basics

My plan is to post a series of hopefully useful and informative vbScript Functions and Subs. I started writing up my first code snippet and found that I was taking too many side trips to explain things about the vbScript syntax and language so I decided to postpone the first snippet until I had completed a vbScript intro.

There has been a lot of interest in scripting languages, most notably Perl and Python. While decidedly less versatile and powerful than Python, vbScript (which is way down on the list) has several good points to recommend it.

  1. It has a simple syntax
  2. It doesn't require a complex development environment
  3. It comes with every version of Windows
  4. Carefully written code can be easily ported to vb.Net
  5. It's great at tying software together/automating

The simple syntax still requires some effort to learn and some documentation. Even though Microsoft includes vbScript (cscript/wscript) with Windows, for some reason they have removed all traces of the associated help file, script56.chm. I've attached a zipped copy of that file with this post. Ignore the parts that relate to jscript.

Point number 2 notwithstanding, I find that having Visual Studio installed makes debugging much simpler as you can use the VS debugger to watch/single step through code just like you would a vb.Net or C# application.

For editing source code, while Notepad would do the job, there are much better (and free) editors available. While not free, I use TextPad and …

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I'm assuming that >30 means expired so why not just do a case in the query that returns a value for Expired (or unexpired) of True or False. That way if the subscription period changes, all that would need to be modified is a stored query. For that matter, instead of a stored query the OP could just create a view which calculates the True/False value as a field named Expired.

David_133 commented: Can I have an example as illustration of what you just said ? +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Where I used to work, we standardized our date formats on all computers and databases/apps as yyyy-mm-dd. For one thing it made comparing dates trivial.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

How do you know that each row corresponds to the same numbered record? In your situation you should be selecting the record that contains that word. It should be set up so that the table is indexed by the word. An example structure would be

Table Words
    Esperanto
    English

SELECT English FROM Words WHERE Esperanto = 'elephanto'

Words could also be set up with a secondary index on English to facilitate a reverse lookup.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Of course it fetches all the words. That's what you are telling it to do. In order to restrict what gets returned you have to provide a WHERE clause as in

SELECT <fieldname> FROM ,tablename> WHERE <fieldname> <condition> <fieldvalue>

For example

SELECT FirstName, LastName FROM Employees WHERE EmployeeID = 221078

If you do that you get one record. If you leave out the WHERE clause you get records for all employees.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Why don't you just ban the members who are spamming?

We do. They just create new accounts.

What's the turnaround time for creating a new email account to spam from?

It's just a few minutes. Unfortunately.

Block both by IP address and by email credential.

Doesn't help when the spammer uses a vpn.

rproffitt commented: Much of this shows why a spambot is required with evolving rules. +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I think I suggested a while back that the mods should have a toggle button available to show/hide deleted threads. Surely the logic already exists to show/hide because non-mods are not able to see deleted threads.

So I guess I now have two requests

  1. show/hide deleted threads button
  2. autoclose of threads older than 6 months

I'm re-requesting #2 because I just saw another 8 year old thread revived for no good reason.

rproffitt commented: Ahh, as in operant conditioning, seeing all that spam is negative conditioning. Why did I click that? Ouch. +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Using Task Manager, what apps are using the most CPU and memory? If you go to the Performance Tab and click on Open Resource Monitor (bottom of screen) you may get more useful info.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

the number of posts per day have dwindled there as well

Maybe people would rather just go to Facebook and nowhere else.

If you go to the Daniweb home page it is surprisingly uninspiring. It doesn't have a "front page" feel. It looks more like I got dropped at some random place in the site. In fact, the only place I see "IT" is in the tab text. There is nothing that says what Daniweb is. The first thing that grabs my eye is the thread summary for the top thread which is

Gave Reputation to JamesCherrill in Biggest DaniWeb pain points

What would that mean to a first-time visitor?

rproffitt commented: That's a good point. For Daniweb the front/home page is a pain point. Where am i? What is this place? +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Try

cmbSearch.CommandText = "SELECT Assignment FROM Apu WHERE StudentID = '" & txtStudentID.Text & "';"

The format is

SELECT <fields> FROM <table> WHERE <conditions>

I strongly suggest, however, that instead of building queries by concatenation you use parameterized queries.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Make sure you have only one anti-virus package running. You might also try disabling your anti-virus (temporarily) to see if that speeds things up. If that works then it is time to switch to another anti-virus.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I read the forums, and saw people raising issues that occurred to me who were poo-pooed without the chance to explain further

I think it would have been appropriate, then, for you to have stepped in to question the response of the poo-pooer. There have been several instances where I have been called on my responses and I have either defended them or, when appropriate, apologized. Staying silent accomplishes nothing. I have found that in the main, people here are reasonable and willing to listen to differing opinions.

ernie.cordell commented: You're absolutely right. I projected failure instead of taking action. I wouldn't have done that in a public meatspace, but online, wilting was easy +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

What are the biggest pain points you have with DaniWeb?

  1. spammers
  2. people who copy/paste homework
  3. people who revive multi-year old threads by posting nonsense
  4. people posting in the wrong area (e.g. programming questions in the Community area)

If you don't visit DaniWeb as much as you used to, what changed?

There's just not much of interest going on. There are few questions in my skill set that I feel capable of answering and most of the ones that are in my area are so simple that it is obvious that the OP just couldn't be bothered to even try to do it his/herself.

There used to be interesting discussions in the geek lounge but that area is just stagnating now.

Where do you go now instead of DaniWeb?

Nowhere. I haven't found anything comparable.

What makes other resources better?

Don't know. Haven't been there. My interest at the moment is in GPU programming (CUDA, OpenCL) and APL and I tend to get answers when needed directly from the vendors.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Skype is worse since m$ took it over. First of all, I amn unable to defer/block updates while at the cottage but more importantly, there is now no way to block unsolicited requests to "kissieface wants to be added as a contact". Fortunately instead of getting 5-6 of these requests per day I now only get 1-2 per week. Still, I should be able to block all contact requests.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

And what is your question?

Before you reply I suggest that you read the Daniweb Posting Rules and Suggestions For Posting Questions.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I am going to retire pretty soon

Welcome back and congrats. I retired in 2008 and haven't spent one second regretting it.

and how wonderful the Amiga was

You and I may be the only ones here like that. Of course, I imagine most people here were born post-Amiga. I was an early adopter with one of the original Amiga 1000 computers. I loved showing it off at work and my kids loved the games (Mindwalker, Marble Madness, etc.). Ever come across any way to set up a vmWare Amiga under WIndows? I wouldn't mind booting into one for nostalgia.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster
  1. whby do you have to convert it?
  2. why can't you convert it?
  3. are there any error messages?
  4. what is the platform (windows/linux)?
  5. what compiler are you using?
  6. are you having any specific problems?
  7. what does the code do?

You want help but you can't be bothered to provide any details. The code is uncommented and I strongly suspect it was written by an engineer (based on the non-descriptive variable names).

At least, I am assuming you want help. Surely you wouldn't just post your code and expect someone here to convert it for you.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Whatever language you choose, become familiar with it before you try to do anything complex.

rproffitt commented: Great advice for both spoken and the written word. +15
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Start with pseudo-code. Instead of coding (telling the computer how to do it), pretend you are writing instructions to tell a human how to do it.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You obviously didn't read the rules Daniweb Posting Rules or Suggestions For Posting Questions or you would have

  1. shown proof of effort
  2. chosen a more descriptive thread title
  3. asked for help instead of demanding a solution
tinstaafl commented: 4. proofread your posts :) +14
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You don't need a special keyboard. It just takes a little while to recall which keys are for which symbols. Lower/upper case letters are as you would expect. More common operators are alt+key. Shape (Greek rho) it alt+r. Iota is alt-i and if it is anything like MicroAPL, there is a pop-up symlist attached to a menu key that displays a clickable table of all special symbols.

The Dyalog version is more comprehensive and also supports multithreading/parallelism/concurrency. I requested a personal licence and received one within the hour. They hit me with a surprise, though. I had to download the software within 14 days. Unfortunately

  1. I am at the cottage with a small data-cap (3 gig a month)
  2. The download was 250(ish) meg

Fortunately I was able to use TeamViewer to remote into a computer at home and do the download to my home computer. Gotta love TeamViewer.

I'm looking forward to trying out Dyalog when I get home in September. Number one just started a research position in Cambridge and is very interestd in parallel processing (he has to crunch large sets of data). Currently Dyalog does not support GPU programming but it seems like it would be a great fit.

rproffitt commented: Είναι ελληνικό για μένα. +15
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You'll notice I waited until all the heavy lifting was done ;-P

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

The criterion was "if more than two features do not match they are denied". In that case

IF no-match <1
    PRINT 'denied'

should be

IF no-match > 2
    PRINT 'denied'

and you will want to keep track of the denials via a counter as in

IF not 'photo' skin tone match 'scanned photo' THEN
    increment no-match
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

A huge problem I had to deal with several times over the years is the programmer who overestimates their abilities. I would much rather work with a programmer like you than one of those yobs.

dudeserius commented: Ditto. Honesty upfront saves the fresh dev a lot of stress, saves the senior dev lots of time, and helps them both because the Senior knows to mentor. +1
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Two People You Should Never Trust: A religious leader who tells you how to vote, and a politician who tells you how to pray.

  • Unknown
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Please explain. When I ran it with some numbers, my output was

Interest = 1976.07

What were you expecting?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Beware of RAS syndrome ;-)

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

System Idle Process is just unused cycles. The higher this number the less busy your CPU is.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

That may be the case except that without seeing all the code we don't know if it was declared at a higher scope.

Santanu.Das commented: Should be correct +8
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

APLX is a very complete implementation of the APL programming language from MicroAPL. The company stopped producing it in 2016 and it has been taken over by Dyalog. While Dyalog charges for the new versions, the final version from MicroAPL is available for free at this page. It comes complete with several pdf manuals. For anyone who is interested in something completely different, I strongly suggest you get this while it is still available for free. It is available in 32 bit and 64 bit for linux, Mac and Windows.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

What line is giving you the error?

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

I don't much care for Qwant's policy of serving up news I did not request.

rproffitt commented: Also, any pop up with "Wait, before you go" and "allow notifications" on many sites today. +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

You are not protecting yourself by using a different delimiter. You protect yourself (one way) by using parameterized queries. For example, if you have a textbox on a form where a user is building a search query and the user is expected to type in a field to search for, let's say a last name, with the resulting query something like

SELECT * FROM someTable WHERE last_name = 'Jones'

where Jones is entered by the user. What would happen if instead of entering Jones, the user entered Jones'; drop table someTable. In that case the resulting query would be

SELECT * FROM someTable WHERE last_name = 'Jones'; drop table someTable

I may not have the syntax exactly right but you get the idea.

rproffitt commented: Always did have a fondness for "Little Bobby Drop Tables." +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

If you are just learning IT security then you should first learn the definitions of

  1. ASCII
  2. SQL Injection Attack

before asing the question. ASCII is a mapping of bit patterns onto characters (EBCDIC and unicode are two others). SQL injection is a method of embedding unwanted (to the atackee) SQL commands in other legitimate commands. It is independent of the character encoding.

rproffitt commented: I'm going to test someone with my EBCDIC SQL INJECTION TEST next. +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

On reflection, I should have titled this thread Cude-like GPU Programming on AMD Radeon.

rproffitt commented: Dad response. Hello Cude. +15
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

There is a cult of ignorance in the United States, and there always has been. The strain of anti-intellectualism has been a constant thread winding its way through our political and cultural life, nurtured by the false notion that democracy means that "my ignorance is just as good as your knowledge."

  • Isaac Asimov
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

And if you can't remove the drive and have to run a recovery program, run it from some other media like a USB stick.

rproffitt commented: Thanks for adding this option. +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Perhaps the challenge was to see how the applicant deals with an incomplete spec. I don't consider that a waste of time at all.

rproffitt commented: I agree. Most projects I've been on have deficits in the specs. +15
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

And clarity has been completely sacrificed.

rproffitt commented: At least it doesn't look plagiarized. +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

It's what I asked for but it's not what I want.

Typical user response upon receiving software.

rproffitt commented: Also, most clients. +0
JamesCherrill commented: So true +14
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Let's look at the specifications:

  1. output the number and “FOO” only when the integer is divisible by 3

Clear and concise.

  1. output the number and “BAR” only when the integer is divisible by 5

Also clear and concise.

  1. but when the integer is divisible by both 3 and 5 then don’t write the above, output the number and “BAZ” instead

Still clear.

  1. Take into consideration that we might want to add new rules in the future including different numbers, operators and iteration patterns.

Here's where we get into trouble. As a software developer I would refuse this request on the basis of too little detail. If I was still forced to provide a solution I would provide (minus the input validation and /help text)

for i = 1 to num
    select case i mod 15
        case 0       : Wscript.Echo i, "BAZ"   'divisible by 3 & 15'
        case 3,6,9,12: Wscript.Echo i, "FOO"   'divisible only by 3' 
        case 5,10    : Wscript.Echo i, "BAR"   'divisible only by 5'
        case else    : Wscript.Echo i          'everything else    '
    end select
next

The code is almost self explanatory and requires only minimal commenting. It would be easy for someone to modify for other multiples. A spec that says "we may want to add new rules" is too vague to be worth anything more than derisive laughter or a short sneer. In an interview I would say that I would reject such a spec. I wouldn't work for a …

rproffitt commented: Or "Muhaha" as you code darkly. +15
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Beware of the double-dot problem. This occurs when using an Excel object from within another application. Instantiate intermediate objects before you use them. For example, use a local variable for the sheet object then operate on stuff in the sheet using that object. If you don't then multiple copies of Excel will be left in memory. This is also known as the one-dot rule.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

The nice thing is we can infract/ban and still leave the post visible as a warning to others.

For those people who don't see the harm in having someone else do their homework, how would you like to get surgery from a doctor who got his medical degree that way? If my doctor is cutting anything I would prefer it to not be "corners".

ddanbe commented: Quite right! +0
rproffitt commented: Quite nice about this. +0
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

This is a standard homework problem and we don't do homework.

Schol-R-LEA commented: I would say it comes up more as a standard interview question, but since we don't do those either, it amounts to the same thing. +13
rproffitt commented: Shame folk seem to aks others to do their homework. +15
Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

A c++ program that prompts the user to input "I want someone else to do my homework for me with absolutely no effort on my part". If the person inputs "yes", it outputs "failed" then prompts the user to show a little effort before running again.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

If you go to bing and search for goggles the first hit on the list is google. That ought to tell you something.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

And lose the GOTO. There are times when a GOTO is acceptable, even preferable, to the structured equivalent. This is not one of them.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

RE: tire analogy, I can see whan a tire is flat. I can't see when a CMOS battery is dead. Also, CMOS batteries last for years so I would imagine most people would opt for a newer, faster computer when faced with a possible couple of hundred for a repair bill. Some people, like my father-in-law, are just looking for an excuse to get a newer computer.

Personally, I still have an old IBM ThinkPad from 2004 that I keep running even though the hinges are toast (the lid is epoxied into position). Of course, I also have a new laptop. I'm not completely dim.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

He hasn't been on Daniweb for four years. Please do not revive old threads. Start a new thread with your question.

Reverend Jim 5,225 Hi, I'm Jim, one of DaniWeb's moderators. Moderator Featured Poster

Easily done, but what do you do if the folder contains an executable or an image file?You don't want to delete ^M in those.