Solved

Simple VB Command

Posted on 2006-07-07
15
355 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 66

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 66

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
Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

 
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 66

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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…

724 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