Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
  #1  
Old June 18th, 2003, 03:27 PM
merlincode merlincode is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2003
Posts: 7 merlincode User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
vb to vbscript

Hey all,

I'm trying to convert a visual basic app I wrote into vbscript. The application is pretty simple. It gets the system time, converts all bad characters to dashes and makes a folder of the date and time.

Below is the vbscript code that I have wrote. When I run the file from the command prompt (with cscript) I get a "type mismatch 'mid' " error.

ANy help/advice is appreciated!

Function CreateFolderDemo

Dim fso, f, timeStamp, stringLength, count, newTimeStamp, colonLoc, dashLoc, colonChar, dashChar

count = 1
timeStamp = Now
newTimeStamp = timeStamp
stringLength = Len(timeStamp)
colonChar = ":"
dashChar = "/"

Do While count < stringLength

'Returns the character locations
colonLoc = InStr(count, timeStamp, colonChar, 0)
dashLoc = InStr(count, timeStamp, dashChar, 0)

'Modifies the characters in the string
If Not colonLoc = 0 Then
Mid(newTimeStamp, colonLoc) = "-"
End If

If Not dashLoc = 0 Then
Mid(newTimeStamp, dashLoc) = "-"
End If

count = count + 1

Loop

Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.CreateFolder("c:\" + newTimeStamp)
CreateFolderDemo = f.Path

End Function

call createfolderdemo()



Thanks,

Mark

Reply With Quote
  #2  
Old June 18th, 2003, 03:47 PM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,827 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 22 h 57 m 29 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
Ok, this is what I came up with. It is a little bit different that what you are attempting to do, and a little more direct.
Code:
Function CreateFolderDemo

	Dim fso, f, timeStamp, stringLength, newTimeStamp, colonChar, dashChar, spaceChar, replaceChar

	timeStamp = Now
	newTimeStamp = timeStamp
	colonChar = ":"
	dashChar = "/"
	spaceChar = " "
	replaceChar = "-"

	newTimeStamp = Replace(newTimeStamp, colonChar, replaceChar)
	newTimeStamp = Replace(newTimeStamp, dashChar, replaceChar)
	newTimeStamp = Replace(newTimeStamp, spaceChar, replaceChar)
	

	Set fso = CreateObject("Scripting.FileSystemObject")
	newTimeStamp = "c:/" & newTimeStamp
	Set f = fso.CreateFolder(newTimeStamp)
	CreateFolderDemo = f.Path

End Function

call createfolderdemo()


The reason for the error you are getting is because the Mid() function returns a value, you can't set a value in this manner.

Reply With Quote
  #3  
Old June 18th, 2003, 03:51 PM
Onslaught's Avatar
Onslaught Onslaught is offline
/(bb|[^b]{2})/
Dev Shed Demi-God (4500 - 4999 posts)
 
Join Date: Nov 2001
Location: Somewhere in the great unknown
Posts: 4,827 Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level)Onslaught User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 1 Day 22 h 57 m 29 sec
Reputation Power: 88
Send a message via ICQ to Onslaught
Another good bit of advice I could offer possibly is two things...
1) I would see if I could find the VBScript, Introduction to Windows Script Components, and Windows Script Host Reference help manuals. They are in compiled help format. These came on my computer in the directory:
C:\VALUEADD\MSFT\XTRADOCS\SCRIPT

2) A quick little tip on how to echo out content you can use WScript.echo "what ever you want to echo goes here"

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > vb to vbscript


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway