• 0

VB Noob - Curious About Commands


Question

I am an absolute noob to VB. I'm kind of crashing myself into it because of my situation. I fell in on a network that was already in place. The guys here before me wrote some scripts in VB that automatically map network printers, shared folders, etc. The only problem is that they've been around for about 5 years and gone through two or three groups and have become quite bloated, and buggy. One thing they do is redirect everyone's home directory to our server. So, seeing as I don't know enough about VB to modify the ones in existence (comfortably anyway) I'm writing a brand new one. I've never written VB before, so I'd like you to look over the code I've written so far and tell me if it would work. I've written it only to do the two tasks I want it to do, map network drives and printers.

Also I was wondering what the "Dim" before variables does? I've seen it in example scripts that I googled, and the scripts that are in existence.

Attached is a .txt version of what I've got written so far.

mapresources.txt

Link to comment
https://www.neowin.net/forum/topic/704818-vb-noob-curious-about-commands/
Share on other sites

11 answers to this question

Recommended Posts

  • 0
... I was wondering what the "Dim" before variables does? .

It declares the name of the variable, ie it says "I';m going to use the name "Network" for my variable - without it the compiler wouldn't know if you mis-typed the name later, it would just have to assume it was a new variable. In most other languages there is something equivalent, but it usually defines what sort of variable it is (number, string etc) as well.

  • 0

Without "Dim" I don't even think the compiler would realise it is a variable would it? It would just give an error I think? It's been a whole year since I last did VB, but I can tell you that "Dim" before a variable name just declares that it is a variable (like JamesCherrill said) :)

  • 0

Ah, blessed VB syntax, well, VBScript syntax anyway.

I'm not gonna rehash what others have said, I'd simple say the script looks fine, but I would include some error checking if operations fail.

I've always been confused over the origin of Dim. I believe its short for Dimension (as in allocating a dimension of memory for the object). Others have said it means "Declared-in-Memory". Confuzzles me!

  • 0
I've always been confused over the origin of Dim. I believe its short for Dimension (as in allocating a dimension of memory for the object). Others have said it means "Declared-in-Memory". Confuzzles me!

"Dimension" is what one of the examples in the QuickBASIC 4.5 help file says. In one of the examples that the help file gives, it has a comment that says "Dimension an array to hold the values." That's why I've always thought it meant "Dimension". "Declared-In-Memory" is a new one to me. ^_^

No, I don't use it anymore. I think I just keep it around for nostalgia. The days of a blue screen that didn't mean something was wrong with your computer were nice. :D

  • 0

I think it's "Dimension" based on the original usage which was to specify the dimensions of an array, eg

dim months(12), chessboard(8,8)

some of the early Basics I've used didn't need variables to be Dim'ed unless they were arrays, which led to horrendous debugging problems when you mis-spelled a variable name.

  • 0
I think it's "Dimension" based on the original usage which was to specify the dimensions of an array, eg

dim months(12), chessboard(8,8)

It is "Dimension". Even if it wasn't an array, it still used an array of bytes for storage...

some of the early Basics I've used didn't need variables to be Dim'ed unless they were arrays, which led to horrendous debugging problems when you mis-spelled a variable name.

Urgh. Nasty version of BASIC you had there. All the ones I've used (since 1979) have required Dim to declare variables, even the quite horrible Sharp BASIC running on a MZ-80K. One notable exception ISTR is ZX81 BASIC which had Let as well. I can't remember if BBC BASIC had that as well. I wouldn't be surprised...

  • 0

Alright, the script is operational, however something is wrong with some of the computers and when trying to connect to the shared printers they fail 9 times out of 10, and I have to manually restart the "Print Spooler" service. I want to add a line to the end of the script to tell it to start that service just in case this happens. What commands could I use in VBScript to do this? Can I insert normal CLI commands into a VBScript?

P.S. What are some good VBScript tutorials that I could use? I'm looking for free online books, online tutorials, etc.. Something along the lines of VBScript for dummies that could take someone who doesn't know anything about it and make them somewhat comfortable.

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • I agree. I also think Phil stayed too long. They should definitely fire whoever thought all a console platform needed was Call of Duty, Elder Scrolls, and Fallout to survive. Asha and crew are still saying they need more Elder Scrolls and Fallout games. They simply don't get it.
    • Macbook Air is an appealing option, as are plethora of Windows devices with various different CPU's
    • Mozilla highlights Firefox Nova 2026 redesign and more upcoming features with new roadmap by Sayan Sen Last month Mozilla confirmed that Firefox was set to get a major redesign this year. Dubbed "Project Nova", it can already be tested and will roll out to all users later this year.The idea is to keep the browser competitive in a rapidly evolving internet landscape. As such the revamp focuses on improving privacy, usability, performance, accessibility, and customization. Key privacy features including the built-in VPN, private browsing mode, and Enhanced Tracking Protection, will be more visible and easier to manage, while users will have the option to disable AI features entirely through a dedicated kill switch. Additionally, the redesign promises faster page loading, the return of Compact mode, expanded personalization options, and stronger accessibility support. You can find the full details in the dedicated piece linked above. In a new blog post today the company once again reiterated on Nova and also emphasized other new and upcoming features like the settings revamp that is intended to make it easier for users to understand browser settings. In order to make it simpler for users to keep up with such features Mozilla today is launching Firefox roadmap. Hence enthusiasts and interested users will be able to check out what's cooking and also share feedback about the upcoming additions. Alongside the roadmap announcement, Mozilla also highlighted what's new in Firefox 152. One of the biggest additions is the arrival of Tab Groups on Android. The feature, which has already been helping desktop users organize large numbers of tabs, is now beginning to roll out on mobile. Users will be able to group related tabs together, assign names and colors to them, and return to them later. Mozilla says support for iOS will arrive later this year. Firefox 152 also introduces the aforementioned redesigned Settings experience. The company says the changes are meant to make controls easier to find and help users discover features they may not have previously known about. Existing preferences are not changing, though they are now better organized. Another notable addition is the new Blocked Tracker Widget, which provides a visual overview of Firefox's privacy protections by showing how many trackers have been blocked over time and the types of tracking activity the browser has stopped. Looking ahead, Mozilla revealed several upcoming roadmap features. They include customizable keyboard shortcuts, as well as enhanced PDF editing tools that will allow documents to be split, merged, and reorganized directly within Firefox. The company is also working on bringing Multi-Account Containers into the native Firefox experience thus removing the need for a separate extension. Meanwhile Firefox's built-in VPN is set to expand to mobile devices. Mozilla is also developing AI-powered features like Quick Answers, which can provide concise responses to voice queries, and Smart Window, its optional AI browsing experience that is now available without a waitlist. Finally, a new Power Saving Mode is in the works and will help reduce the impact of resource-heavy tabs on mobile devices in order to extend battery life. The video below summarizes the upcoming changes in an easy to understand format: You can find the announcement blog post here on Mozilla's official website.
    • Dead on arrival at that price. Like they missed the mark by multiple hundreds of dollars - this should actually undercut the Macbook Air at $899 if they want any sort of sales / further adoption of WoA
  • Recent Achievements

    • One Year In
      Console General earned a badge
      One Year In
    • One Year In
      Twozo Technologies earned a badge
      One Year In
    • One Month Later
      Twozo Technologies earned a badge
      One Month Later
    • Week One Done
      Twozo Technologies earned a badge
      Week One Done
    • Veteran
      branfont went up a rank
      Veteran
  • Popular Contributors

    1. 1
      +primortal
      513
    2. 2
      +Edouard
      196
    3. 3
      PsYcHoKiLLa
      109
    4. 4
      Steven P.
      89
    5. 5
      Nick H.
      71
  • Tell a friend

    Love Neowin? Tell a friend!