Solved

Simple VB Command

Posted on 2006-07-07
15
354 Views
Last Modified: 2012-05-05
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
0
Comment
Question by:Will Szymkowski
[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
  • Learn & ask questions
  • 4
  • 3
  • 3
  • +2
15 Comments
 
LVL 65

Expert Comment

by:Jim Horn
ID: 17058702

Select Case Right(YourBarCode, 1)
  Case 4
      YourLabelName.Caption = 'LP'
   Case 7
      YourLabelName.Caption = 'RD'
End Select
0
 
LVL 53

Author Comment

by:Will Szymkowski
ID: 17058807
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
 
LVL 65

Expert Comment

by:Jim Horn
ID: 17058837
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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 17058838
Hi Spec01,

Use double quotes instead of single quotes.

Regards,

Patrick
0
 
LVL 92

Expert Comment

by:Patrick Matthews
ID: 17058842
Jim,

Sorry :)

Regards,

Patrick
0
 
LVL 53

Author Comment

by:Will Szymkowski
ID: 17058866
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
 
LVL 65

Expert Comment

by:Jim Horn
ID: 17058883
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
 
LVL 53

Author Comment

by:Will Szymkowski
ID: 17059144
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
 
LVL 9

Expert Comment

by:lojk
ID: 17059270
perhaps a checksum * either side?


  Case 4
      Database.Caption = "*LP*"
   Case 7
      Database.Caption = "*RD*"
0
 
LVL 9

Accepted Solution

by:
lojk earned 350 total points
ID: 17059305
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
 
LVL 9

Expert Comment

by:justchat_1
ID: 17061384
Use the first one...
0
 
LVL 9

Expert Comment

by:justchat_1
ID: 17291848
lojk had the correct answer
0
 
LVL 53

Author Comment

by:Will Szymkowski
ID: 17318560
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
 
LVL 9

Expert Comment

by:lojk
ID: 17319149
Only *so many* ways to skin a cat i guess... Thanks for the point/grade etc..
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

726 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