Simple VB Command

Hello Experts,

Need some help writing a small script. We have a label program all barcodes numbers end in either 4 or 7. If the number ends with a 4 then I want to display "LP" on the label. If the number ends in 7 i want it to dispaly "RD". If anyone could write up a small VB script that will work for my needs it would be most appreciated.

Thanks in advance
LVL 53
Will SzymkowskiSenior Solution ArchitectAsked:
Who is Participating?
 
lojkConnect With a Mentor .Net and Infrastructure ConsultantCommented:
Oh, right i get it now...

You are confusing numbers with strings of numbers...

Select Case Right("48544", 1)

 Case "4"
      Database.Caption = "LP"
   Case "7"
      Database.Caption = "RD"

or

Select Case cint(Right("48544", 1))

 Case 4
      Database.Caption = "LP"
   Case 7
      Database.Caption = "RD"
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:

Select Case Right(YourBarCode, 1)
  Case 4
      YourLabelName.Caption = 'LP'
   Case 7
      YourLabelName.Caption = 'RD'
End Select
0
 
Will SzymkowskiSenior Solution ArchitectAuthor Commented:
Hey, thanks for the fast response. I'm getting the following error when I use the following command:

The Following script error was found:

OnAutoSelectdEvent(Line 3):   Database.caption = 'LP':syntax error

0
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
Oops, use double-quotes instead of single quotes (I was thinking SQL Server for some reason).  

Select Case Right(YourBarCode, 1)
  Case 4
      YourLabelName.Caption = "LP"
   Case 7
      YourLabelName.Caption = "RD"
End Select
0
 
Patrick MatthewsCommented:
Hi Spec01,

Use double quotes instead of single quotes.

Regards,

Patrick
0
 
Patrick MatthewsCommented:
Jim,

Sorry :)

Regards,

Patrick
0
 
Will SzymkowskiSenior Solution ArchitectAuthor Commented:
Ok, here is what I have put down. Sorry I'm not a programmer ;- P.

Select Case Right(48544, 1)
  Case 4
      Database.Caption = "LP"
   Case 7
      Database.Caption = "RD"
End Select

This is the error I'm getting now...

OnAutoSelectedEvent(Line 3): : Object required: ''
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
If 'Database' is the name of your label, it would probably be a good idea to rename it (lbl_database comes to mind), in case VB is confusing it with a database object.  

0
 
Will SzymkowskiSenior Solution ArchitectAuthor Commented:
Still having no luck....

The command seems to be error free, but when I print something LP or RD isn't showing up. The program I'm using BarTender Label software.

Anymore help would be appreciated.

Thanks
0
 
lojk.Net and Infrastructure ConsultantCommented:
perhaps a checksum * either side?


  Case 4
      Database.Caption = "*LP*"
   Case 7
      Database.Caption = "*RD*"
0
 
justchat_1Commented:
Use the first one...
0
 
justchat_1Commented:
lojk had the correct answer
0
 
Will SzymkowskiSenior Solution ArchitectAuthor Commented:
With regards to this queestion, I have still been working on a solution. I was just waiting to see if there would be more answers provided.
0
 
lojk.Net and Infrastructure ConsultantCommented:
Only *so many* ways to skin a cat i guess... Thanks for the point/grade etc..
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.