?
Solved

Simple VB Command

Posted on 2006-07-07
15
Medium Priority
?
356 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 93

Expert Comment

by:Patrick Matthews
ID: 17058838
Hi Spec01,

Use double quotes instead of single quotes.

Regards,

Patrick
0
 
LVL 93

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 1400 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month10 days, 14 hours left to enroll

770 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