PDA

View Full Version : VBS question


guineapig
01-07-2010, 05:48 PM
Hey fellow geeks.

Quick VBS question.
I have a script here for a basic keygen. It works fine except for one thing.
After you type in (for example) 2-3 digit number and the key is generated you click okay and it goes back to the window requesting another session key.

That part is fine. However, when I click close (x) it brings up the generated number again. Also if you click close (x) on the window with the generated key it also takes you back to the window requesting another key.

Here's the code:
---------------------------------
On Error Resume Next

Dim Key, tempString, tempKey, Input

Do

Input = InputBox("Enter Serial!")
Input = int(Input)

Key = ((((((((Input ^ 8) / 92657) + 16) * 7) / 316) - 23) / 71104) + 26) * 24

tempString = CStr(Key)
tempString = Left(tempString, 6)
tempKey = Int(tempString)

if (tempKey < 1000000) then
tempString = CStr(tempKey * 2540)
tempString = Left(tempString, 6)
Key = Int(tempString)
else
Key = tempKey
end if

msgbox (Key)

Loop Until Input < 1
-----------------------------------------

How the hell do I get the code to terminate the script as soon as the close (x) click event happens???

I cant think of a bunch of ways to do it logically but I really suck at VBS and can't figure out the syntax. Any help would be greatly appreciated.

This is just for home computer use so feel free to use the code for whatever if you want to...

guineapig
01-07-2010, 06:00 PM
Oh, in case anyone is curious. Just paste the code into a text file and save it as a .vbs file. Then you can double click on it to run and see how it works currently.

Goobles
01-07-2010, 08:50 PM
Reported.

karsten
01-07-2010, 10:09 PM
http://fbcmoline.files.wordpress.com/2009/06/vacation_bible_school1.jpg

Goobles
01-07-2010, 10:33 PM
Sad.

guineapig
01-08-2010, 12:16 AM
Am I missing something???

Allizia
01-08-2010, 12:29 AM
End select instead of end if? I have basic knowledge at best

:confused:

guineapig
01-08-2010, 09:20 AM
End select instead of end if? I have basic knowledge at best

:confused:

I'll certainly try it... anyone else?

xxxbeinxxx
01-26-2010, 06:29 PM
This fixes the issue you described, but you need to validate your input to make sure the value isn't equal to null.

Dim Key, tempString, tempKey, Input

Input = InputBox("Enter Serial!")
Input = int(Input)

Key = ((((((((Input ^ 8) / 92657) + 16) * 7) / 316) - 23) / 71104) + 26) * 24

tempString = CStr(Key)
tempString = Left(tempString, 6)
tempKey = Int(tempString)

if (tempKey < 1000000) then
tempString = CStr(tempKey * 2540)
tempString = Left(tempString, 6)
Key = Int(tempString)
else
Key = tempKey
end if

msgbox (Key)