In English Please?!

Posted on 2009-03-30
Medium Priority
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

Question by:Pearl_export_ben
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
  • Learn & ask questions
LVL 53

Accepted Solution

Dhaest earned 2000 total points
ID: 24018252
Inst function

Mid Function (Visual Basic)  

Left function
' 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	
   end if

Open in new window

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.

Author Closing Comment

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

Featured Post

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…
Suggested Courses
Course of the Month8 days, 18 hours left to enroll

764 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