Print Page | Close Window

ASP return part of a string

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=11605
Printed Date: 31 March 2026 at 1:17am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: ASP return part of a string
Posted By: velkymx
Subject: ASP return part of a string
Date 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!



Replies:
Posted By: dpyers
Date 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.



-------------

Lead me not into temptation... I know the short cut, follow me.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net