Photo Gallery Member List Search Calendars FAQ Ticket List Log Out


VBS: Find number in String and increase

 
Logged in as: Guest
arrSession:exec spGetSession 2,2,47315
 Active Users: There are 0 members and 0 guests.
 Users viewing this topic: none
 

 

 
  
  Printable Version
All Forums >> [Scripting] >> WSH & Client Side VBScript >> VBS: Find number in String and increase
  Do you like VisualBasicScript.com? Link to us and help spread the word about our forum. Thanks!
Page: [1]
Login
Message << Older Topic   Newer Topic >>
 VBS: Find number in String and increase - 5/21/2007 7:55:33 AM   
  Stefans

 

Posts: 6
Score: 0
Joined: 5/21/2007
Status: offline
May i ask if somebody can point me to the right direction?

VBScript
* I want to read text line and split them in an Array. ( how i get the text i know already )
* Spilt them and find numbers, f.ex. "001, 002, 003..."
* ask the user to de-/increase with an value, f.ex. "1" with an InputBox
* do the expression:  de-/increase  found number with user input
* rebuild the text line into an array for export


Also i like to find an number in an string, decrease or increase them, and output the line. Then i know what to do with the output.


Many thanks to everyone who can help.

Stefan
 
 
Post #: 1
 
 RE: VBS: Find number in String and increase - 5/21/2007 7:56:56 AM   
  ebgreen


Posts: 5250
Score: 31
Joined: 7/12/2005
Status: offline
Your best bet is to post a sample of the data that will be parsed, the code that you have so far, and what you want to come out.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to Stefans)
 
 
Post #: 2
 
 RE: VBS: Find number in String and increase - 5/21/2007 3:34:59 PM   
  Stefans

 

Posts: 6
Score: 0
Joined: 5/21/2007
Status: offline
Sample String:
*I have an text string.
ABC001=
XYZ001=
XXX001=
or what ever like: this is an sample 03 with two numbers 99

*I want to find the number(s)
array(0) = 001
array(1) = 03
array(2) = 99

*I want to increase this number(s)
vINT = InputBox("Amount and plus or minus") ..............or two InputBoxes, one for +/-, one for the amount
vResult = array(n)   +/-   vINT
vResult = array(n)   +/-   vINT
vResult = array(n)   +/-   vINT

*I want the original text string with now increased numbers back.
vOutput=


I think I need only this modul.
The text string comes and goes to an text editor with his build in script engine.
This code i have in other examples and is no part of my request.
Please ask if smtg is unclear.
Thanks for your support.

Stefan

_____________________________

Thanks, Stefan.

(in reply to ebgreen)
 
 
Post #: 3
 
 RE: VBS: Find number in String and increase - 5/22/2007 12:39:12 AM   
  ebgreen


Posts: 5250
Score: 31
Joined: 7/12/2005
Status: offline
Well if the code that you have does not apply to this then perhaps it is time for you to write some code that does apply and post back here when you have specific problems.

_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to Stefans)
 
 
Post #: 4
 
 RE: VBS: Find number in String and increase - 5/22/2007 5:17:01 AM   
  Stefans

 

Posts: 6
Score: 0
Joined: 5/21/2007
Status: offline
quote:

ORIGINAL: ebgreen

Well if the code that you have does not apply to this then perhaps it is time for you to write some code that does apply and post back here when you have specific problems.


Are you kidding?
I can't post an code, i din't have this code,  that's why i'm here.
I ask for help if anybody have the knowledge to show me such an function.

Once again:

I'm looking for an function which handels an text string from an array which I provide.
Then this function should search in this string for an number.
Then this function should increase (or decrease too if it's not too much) the numbers.
Then the function should store this strings back in an array and give it me back.

I can provide e.g.
* strArray --- with all my text separated in lines
* intAmount ---- the userinput with the amount to de-/increase the numbers
* strPlusMinus ---  the userinput to show if the user wants to decrease or to increase.
* any more if you need



Well it's enought:
* to handle lines with ONE number only
* only handle  Integers
* only simple error messages like "error in " & array(x)


Is anybody here to know such an function which I could use?

Thank you
Stefan

_____________________________

Thanks, Stefan.

(in reply to ebgreen)
 
 
Post #: 5
 
 RE: VBS: Find number in String and increase - 5/22/2007 5:22:19 AM   
  ebgreen


Posts: 5250
Score: 31
Joined: 7/12/2005
Status: offline
Did you read the Read Me First post at the top of this forum? The very first thing that it states is:

quote:

We are not here to write scripts for you, we can fully support you in you writing your scripts.  If you make the attempt and are still having issues, we can and will gladly
help you out, you can Search our site for up-to-date information on retrieving objects from AD, read/write to the registry, etc...


_____________________________

"... when you are good and crazy, oooh, oooh, oooh, the sky is the limit!" - The Tick
Goog places to start:http://www.visualbasicscript.com/m_24727/tm.htm
http://www.visualbasicscript.com/m_47117/tm.htm

(in reply to Stefans)
 
 
Post #: 6
 
 RE: VBS: Find number in String and increase - 5/22/2007 7:13:21 AM   
  Skie

 

Posts: 58
Score: 0
Joined: 3/2/2006
Status: offline
First, look up For Next, Mid, and IsNumeric.  Here's a snippet of code to get you started.  You'll need to apply to your code.  If you continue to have issues, post your code.  If the problem is you just don't know VBScript, there are a lot of references out there, so take some time to learn it.


      

(in reply to Stefans)
 
 
Post #: 7
 
 RE: VBS: Find number in String and increase - 5/23/2007 4:26:42 AM   
  Stefans

 

Posts: 6
Score: 0
Joined: 5/21/2007
Status: offline
Ahhh, thanks Skie ...

  If IsNumeric(Mid(sString,i,1))


was the entry point to jump into the coding.
Now i have an start, thank you very much.

_____________________________

Thanks, Stefan.

(in reply to Skie)
 
 
Post #: 8
 
 RE: VBS: Find number in String and increase - 5/23/2007 5:17:40 AM   
  ehvbs

 

Posts: 2223
Score: 50
Joined: 6/22/2005
From: Germany
Status: offline
Hi Stefans,

you could use a RegExp + a replace function:


      

but then you'd first have to specify the format of your possible
input a little bit more precisely to tweak the replace function.

Good luck!

ehvbs

(in reply to Stefans)
 
 
Post #: 9
 
 RE: VBS: Find number in String and increase - 5/26/2007 10:13:50 AM   
  Stefans

 

Posts: 6
Score: 0
Joined: 5/21/2007
Status: offline
Thank you  ehvbs for your help. I miss this post and see it the first time now. Thank you.
It will take some time for me to investigate this.

See you later
Stefan

(in reply to ehvbs)
 
 
Post #: 10
 
 
 
  

If you found our site useful please link to us <a href="http://www.visualbasicscript.com">VisualBasicScript.com</a>.
All Forums >> [Scripting] >> WSH & Client Side VBScript >> VBS: Find number in String and increase Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts