Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - ASP return part of a string
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

ASP return part of a string

 Post Reply Post Reply
Author
velkymx View Drop Down
Groupie
Groupie


Joined: 24 February 2003
Location: United States
Status: Offline
Points: 44
Post Options Post Options   Thanks (0) Thanks(0)   Quote velkymx Quote  Post ReplyReply Direct Link To This Post Topic: ASP return part of a string
    Posted: 23 August 2004 at 2:39pm
OK here is what I am trying to do. I have a string that is being generated, it list the computers CPU and speed. Like this:

Intel(R) Pentium(R) 4 CPU 2.60GHz GenuineIntel 15 0 2 0 9 <>Original FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE-36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM 9 64 2 1

I want to be able to pull out the 2.60GHz part with counting... this could be different for everyone. I can get the prosition of the GHz or MHz (InStr(StrCPU, "GHz"))  - but how do I pull it out? So I want to get it to write out 2.60GHz....

Thanks!
Back to Top
dpyers View Drop Down
Senior Member
Senior Member


Joined: 12 May 2003
Status: Offline
Points: 3937
Post Options Post Options   Thanks (0) Thanks(0)   Quote dpyers Quote  Post ReplyReply Direct Link To This Post Posted: 23 August 2004 at 3:36pm

Dim strStartPos
Dim strEndPos
Dim strLength
Dim strWorkText
Dim strSearchString
Dim strEndStringChars

Sub PullStrings(strSearchString, strEndStringChars)
 strStartPos = 1
 strEndPos = 0
 strLength = 0

 'Find the Start Position of the Search String
 strStartPos = instr(strWorkText,strSearchString)
 
 'Starting from the Search String ,  
 'find the beginning postion of the End String of Chars
 strEndPos = instr(strStartPos + len(strSearchString), strWorkText, strEndStringChars)
 
 'Compute the length of the string in between the start and end positions
 strLength = strEndPos - strStartPos

 On Error Resume Next  'In case anything is screwed up with the start/end strings, this will grab everything
 
 'Pluck the string out of the work text
 strWorkText = mid(strWorkText,strStartPos,strLength)
End Sub

strWorkText = YOUR_STRING

PullStrings "CPU ", " "

The above code will pluck out everything between the characters "CPU " and the next occurrence of the characters " ". It will be put into strWorkText.



Edited by dpyers

Lead me not into temptation... I know the short cut, follow me.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.