Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsProgrammingVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old December 28th, 2004, 12:35 PM
chacquard chacquard is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 1 chacquard User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
String function

Hi,

I need to look for a specific string "Cancel" in a field (form). Whether "Cancel" is found or not, I need to do specific procedures accordingly in VBA.

Does anyone know of a procedure or function to help me...

Thanks

Chantal

Reply With Quote
  #2  
Old December 28th, 2004, 07:13 PM
samdland samdland is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 4 samdland User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hope this helps.
Code:
CheckRec = "Your String"
Checker = Len(CheckRec)
CheckFer = "cancel"
Checker = CountOcc(CheckFer, CheckRec, False)


Code:
Public Function CountOcc(Trigger As String, SourceString As String, CaseSense As Boolean) As Long
   On Error Resume Next
Dim pos As Long
Dim TotalCount As Long
	TotalCount = 0
	pos = 0
	If CaseSense = False Then
		SourceString = UCase(SourceString)
		Trigger = UCase(Trigger)
	End If

	Do While pos <> -1
		pos = InStr(pos + 1, SourceString, Trigger)
		If pos <> 0 Then TotalCount = TotalCount + 1
		If pos = 0 Then pos = -1
	Loop
	
	CountOcc = TotalCount
 Exit Function
  
End Function


Checker will return number of occurrences found

Sam Land
Dynamic DNS Server Suites

Last edited by samdland : December 28th, 2004 at 07:18 PM. Reason: Adding

Reply With Quote
  #3  
Old February 6th, 2006, 04:23 PM
u0107 u0107 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Jul 2005
Posts: 13 u0107 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 4 h 25 m
Reputation Power: 0
Getting error with this code

Hello,

I get the following error:

Error Type:
Microsoft VBScript compilation (0x800A03EE)
Expected ')'
/common_comment_decode.asp, line 54, column 41
Public Function CountOccurrence (Trigger As String, SourceString As String, Flag_1 As Boolean) As Long

The debugger points to the "As" after "Flag_1".

Any pointers / ideas, why?

Thanks in advance,

Uttam
---------------------

Quote:
Originally Posted by samdland
Hope this helps.
Code:
CheckRec = "Your String"
Checker = Len(CheckRec)
CheckFer = "cancel"
Checker = CountOcc(CheckFer, CheckRec, False)


Code:
Public Function CountOcc(Trigger As String, SourceString As String, CaseSense As Boolean) As Long
   On Error Resume Next
Dim pos As Long
Dim TotalCount As Long
	TotalCount = 0
	pos = 0
	If CaseSense = False Then
		SourceString = UCase(SourceString)
		Trigger = UCase(Trigger)
	End If

	Do While pos <> -1
		pos = InStr(pos + 1, SourceString, Trigger)
		If pos <> 0 Then TotalCount = TotalCount + 1
		If pos = 0 Then pos = -1
	Loop
	
	CountOcc = TotalCount
 Exit Function
  
End Function


Checker will return number of occurrences found

Sam Land
Dynamic DNS Server Suites

Reply With Quote
  #4  
Old February 7th, 2006, 07:48 AM
Shadow Wizard's Avatar
Shadow Wizard Shadow Wizard is offline
Moderator From Beyond
ASP Free God 46th Plane (27500 - 27999 posts)
 
Join Date: Sep 2004
Location: Israel
Posts: 27,641 Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)Shadow Wizard User rank is General 14th Grade (Above 100000 Reputation Level)  Folding Points: 374417 Folding Title: Super Ultimate Folder - Level 1Folding Points: 374417 Folding Title: Super Ultimate Folder - Level 1Folding Points: 374417 Folding Title: Super Ultimate Folder - Level 1Folding Points: 374417 Folding Title: Super Ultimate Folder - Level 1Folding Points: 374417 Folding Title: Super Ultimate Folder - Level 1Folding Points: 374417 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 3 Months 2 Weeks 3 h 14 m 36 sec
Reputation Power: 1902
this is not ASP code, it's VB code and can't be used in ASP.
to find sub string in given string in vbscript (ASP), use the InStr function.

Reply With Quote
Reply

Viewing: ASP Free ForumsProgrammingVisual Basic Programming > String function


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT