VBScript Input Box

Microsoft / Vb
May 6, 2010 at 06:45:14
Specs: Windows XP, 3ghz
Hoping someone can help with a vbscript.

Im trying to make a vbscript that is very simple, user just runs script, opens a input box, user types in a country , hits ok, and the script tells what time zone it is. From this point they could enter another country, and so on.

I would of course have a list of pre defined countries and time zones in the script.

can someone help with this ?

thanks,
vic


See More: VBScript Input Box

Report •


#1
May 7, 2010 at 05:31:48
Anyone ?

thanks,
vic


Report •

#2
May 7, 2010 at 05:33:02
I can make the vbscript with msgbox but not sure how to make it so when user puts in country it looks at list ie..

america -5
europe +2
asia +9

and then just give result

thanks,
vic


Report •

#3
May 7, 2010 at 06:36:08
that won't work as-is: f/e: America covers 4 timezones not incl. Hawaii. athough "most" countries are covered by one zone, quite a few span multiple (China, Russia). you would need to code a way to deal with that.
For the database itself, I would use google and find a download of country-to-timezone table.
The actual coding itself (table look-up) it intrinsically simple and presents no problem.

Report •

Related Solutions

#4
May 7, 2010 at 07:02:59
hi, thakns for the reply.
Yes i have downloaded a text file with all countries and timezones.
Basically...
If I type in

america

it should come up and say..

america -5
america -6
america -7

if there is only one, ie.. i type Isreal it should just show
Isreal -2


so it should list all it finds in the text file, that is how I will deal with the different time zones.

thanks,
vic


Report •

#5
May 7, 2010 at 07:16:55
Two ways to handle the lookup, either "inside" the code, or using "find" in a shell (which is the easiest solution).

1)
x=inputbox("country:")
wsh.shell("find /i ""x"" timezns")

or:
for i=1 to ubound(tz)
if ucase(x)=ucase(tz(i,1)) wscript.echo tz(i,2)
next

these examples are just "sketches". They will need to
be filled in with real code.


Report •

#6
May 7, 2010 at 13:48:28
thanks for your input.
I found the solution to this today. It was actually very simple. I have put in about 80 countries so far (just a couple below)

Do
a=inputbox ("please use all lowercase letters to search. Type exit to quit.","TimeZone Finder")

if a = "eniwetok" then
msgbox (a &"-12")
End if

if a = "kwajalien" then
msgbox (a &"-12")
End if

Loop until a = "exit"
x=msgbox("Thank you for using the script")

thanks,
vic


Report •

#7
May 7, 2010 at 15:25:37
simple, yes. easy, NO. althought that will work,
being terminally lazy myself, I would read the file into an array and process it from there:
'adjust this to match the no. of lines in the file
dim ss(2048,2)
dim fso
set fso=createobject("scripting.filesystemobject")
'tztable format one country per line: country comma timediff
'like: america,-5
set fil=fso.opentextfile(".\tztable",1,true)
i=0
on error resume next
do while not fil.atendofstream
i=i+1
x=fil.readline
s=split(x,",")
ss(i,1)=s(0)
ss(i,2)=s(1)
loop
fil.close
'--------- done loading. this does the lookup
x="1"
do while x<>""
x=inputbox("country: ")
if ltrim(x)="" then wscript.quit
x=lcase(x)
xx=""
for i=1 to ubound(ss)
'note: for exact match: if ss(i,1)=x then
if instr(ss(i,1),x)>0 then
t=dateadd("h",ss(i,2),time())
xx=xx&ss(i,1)&" "&ss(i,2)&" Its: "&t&" there."&vbcrlf
end if
next
msgbox xx
loop

Report •

#8
September 28, 2010 at 07:11:16
I need to create a script for the following condition below...can you some one help me on this please.....either it should ask for user to create / either we can call from .csv.


Create user account in the correct OU. This may vary slightly by location
OU path = ad.nyx.com\NYX Support\Users\Offices\(officename)
Office Name may be = Beijing, Brooklyn, Chicago, New York, Palo Alto, San Francisco, Singapore, Tokyo, Washington, Weehawken
First Name
Middle Initial (if applicable)
Last Name
Display Name is First Name Last Name
SamID is 1st initial of first name and last name
Conflicts are by adding middle initial or 2nd letter of 1st name
Set a generic password
Add the following default groups
firewall.remotevpn
LotusNotes8Classic.citrix
xxUsers.DriveMapping
xx = CH, NY, SF or WA depending on location
Create a home folder (users SamID) on \\NYX\Home\(location)
Location = NY, CH, SF, WA
Create a subfolder call Data
Grant the user Full (Modify would suffice) to their home folder


Report •

Ask Question