Solved

Simple VB Command

Posted on 2006-07-07
15
349 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
  • 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
 
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
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…
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…

706 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now