Solved

In English Please?!

Posted on 2009-03-30
3
167 Views
Last Modified: 2012-05-06
Hi guys,

Can someone comment this thoroughly please - I'm a new admin picking up old code :(

500 easy ones.
if len(strjob)>62 then
			
			val=instr(strJob, " - ")
			if val > 2 then strJob=left(strJob, val-1)
		end if
		val=instr(strJob, "-")
		if val > 0 then
			if mid(strJob,1,val-2) = mid(strJob,val+2,len(strJob)) then	strJob=mid(strJob,1,val-2)
		end if

Open in new window

0
Comment
Question by:Pearl_export_ben
3 Comments
 
LVL 53

Accepted Solution

by:
Dhaest earned 500 total points
ID: 24018252
Inst function
http://msdn.microsoft.com/en-us/library/8460tsh1(VS.80).aspx

Mid Function (Visual Basic)  
http://msdn.microsoft.com/en-us/library/05e63829(VS.80).aspx

Left function
http://msdn.microsoft.com/en-us/library/y050k1wb(VS.80).aspx
' check if the length of the string in strJob is longer than 62 charachters
if len(strjob)>62 then
  ' search the position of " - "
  val=instr(strJob, " - ")
  '  if position  is greather than 2, then take only the characters left from the string " - "
  if val > 2 then 
       strJob=left(strJob, val-1)
  end if
 ' search the position of "-"
  val=instr(strJob, "-")
  if val > 0 then
   '  if position  is greather than 0
     if mid(strJob,1,val-2) = mid(strJob,val+2,len(strJob)) then	
          strJob=mid(strJob,1,val-2)
   end if

Open in new window

0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 24018295
When you get the chance, change the name of the variable 'val'. Val is a function name. It extracts a numerical value from the left hand of a String.
0
 
LVL 8

Author Closing Comment

by:Pearl_export_ben
ID: 31564297
Fantastic - commented thoroughly and quickly as requested, thankyou :)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question