Solved

Posted on 2009-03-30
169 Views
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
``````
0
Question by:Pearl_export_ben
[X]
###### Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

• Help others & share knowledge
• Earn cash & points

LVL 53

Accepted Solution

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
``````
0

LVL 76

Expert Comment

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

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

## Featured Post

Question has a verified solution.

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

### Suggested Solutions

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
###### Suggested Courses
Course of the Month6 days, 17 hours left to enroll