Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Help with code please

I am having trouble with a piece of code, the code works with smaller
numbers but when I scan a barcode it does not recognise the number? What
have I got wrong here is the code below.
Private Sub UserForm_Activate()

TextBox1.Value = InputBox("PLEASE SCAN THE ITEM")


End Sub

Private Sub TextBox1_Change()

Dim CHECK1
Sheet5.Activate
On Error Resume Next
CHECK1 = Application.Match(CLng(TextBox1.Value), Range("A:A"), 0)
If Not IsError(CHECK1) Then
Label1.Caption = Application.Index(Range("B:B"), CHECK1)
End If
On Error GoTo 0

End Sub




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Help with code please

What is a typical barcode number that is causing problems. What error
message are you getting?

--
Regards,
Tom Ogilvy


"Greg B" wrote:

I am having trouble with a piece of code, the code works with smaller
numbers but when I scan a barcode it does not recognise the number? What
have I got wrong here is the code below.
Private Sub UserForm_Activate()

TextBox1.Value = InputBox("PLEASE SCAN THE ITEM")


End Sub

Private Sub TextBox1_Change()

Dim CHECK1
Sheet5.Activate
On Error Resume Next
CHECK1 = Application.Match(CLng(TextBox1.Value), Range("A:A"), 0)
If Not IsError(CHECK1) Then
Label1.Caption = Application.Index(Range("B:B"), CHECK1)
End If
On Error GoTo 0

End Sub





  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default Help with code please

this is the example barcode scanned 9310072020280 the code works with
smaller numbers it does not seem to recognise the 9310072020280

There is no error code as such just the caption does not change with the
larger number.

"Tom Ogilvy" wrote in message
...
What is a typical barcode number that is causing problems. What error
message are you getting?

--
Regards,
Tom Ogilvy


"Greg B" wrote:

I am having trouble with a piece of code, the code works with smaller
numbers but when I scan a barcode it does not recognise the number? What
have I got wrong here is the code below.
Private Sub UserForm_Activate()

TextBox1.Value = InputBox("PLEASE SCAN THE ITEM")


End Sub

Private Sub TextBox1_Change()

Dim CHECK1
Sheet5.Activate
On Error Resume Next
CHECK1 = Application.Match(CLng(TextBox1.Value), Range("A:A"), 0)
If Not IsError(CHECK1) Then
Label1.Caption = Application.Index(Range("B:B"), CHECK1)
End If
On Error GoTo 0

End Sub







  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Help with code please

Gregg,
From Help on the LONG data type:

Long (long integer) variables are stored as signed 32-bit (4-byte) numbers
ranging in value from -2,147,483,648 to 2,147,483,647. The type-declaration
character for Long is the ampersand (&).


9,310,072,020,280

is outside this range. Try converting the number to a double (cdbl) since
numbers in the excel sheet are stored as double anyway.

Demo'd from the immediate window:

? cdbl("9310072020280")
9310072020280

--
Regards,
Tom Ogilvy





"Greg B" wrote:

this is the example barcode scanned 9310072020280 the code works with
smaller numbers it does not seem to recognise the 9310072020280

There is no error code as such just the caption does not change with the
larger number.

"Tom Ogilvy" wrote in message
...
What is a typical barcode number that is causing problems. What error
message are you getting?

--
Regards,
Tom Ogilvy


"Greg B" wrote:

I am having trouble with a piece of code, the code works with smaller
numbers but when I scan a barcode it does not recognise the number? What
have I got wrong here is the code below.
Private Sub UserForm_Activate()

TextBox1.Value = InputBox("PLEASE SCAN THE ITEM")


End Sub

Private Sub TextBox1_Change()

Dim CHECK1
Sheet5.Activate
On Error Resume Next
CHECK1 = Application.Match(CLng(TextBox1.Value), Range("A:A"), 0)
If Not IsError(CHECK1) Then
Label1.Caption = Application.Index(Range("B:B"), CHECK1)
End If
On Error GoTo 0

End Sub








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Help with code please

Just to follow up on Tom's reply to you...

The reason you don't see anything is because the number is outside the range
of a Long, your assignment is generating an error, but your On Error Resume
Next statement is hiding that from you. Comment out that statement and you
should be able to see the error.

Rick


"Tom Ogilvy" wrote in message
...
Gregg,
From Help on the LONG data type:

Long (long integer) variables are stored as signed 32-bit (4-byte) numbers
ranging in value from -2,147,483,648 to 2,147,483,647. The
type-declaration
character for Long is the ampersand (&).


9,310,072,020,280

is outside this range. Try converting the number to a double (cdbl) since
numbers in the excel sheet are stored as double anyway.

Demo'd from the immediate window:

? cdbl("9310072020280")
9310072020280

--
Regards,
Tom Ogilvy





"Greg B" wrote:

this is the example barcode scanned 9310072020280 the code works with
smaller numbers it does not seem to recognise the 9310072020280

There is no error code as such just the caption does not change with the
larger number.

"Tom Ogilvy" wrote in message
...
What is a typical barcode number that is causing problems. What error
message are you getting?

--
Regards,
Tom Ogilvy


"Greg B" wrote:

I am having trouble with a piece of code, the code works with smaller
numbers but when I scan a barcode it does not recognise the number?
What
have I got wrong here is the code below.
Private Sub UserForm_Activate()

TextBox1.Value = InputBox("PLEASE SCAN THE ITEM")


End Sub

Private Sub TextBox1_Change()

Dim CHECK1
Sheet5.Activate
On Error Resume Next
CHECK1 = Application.Match(CLng(TextBox1.Value), Range("A:A"), 0)
If Not IsError(CHECK1) Then
Label1.Caption = Application.Index(Range("B:B"), CHECK1)
End If
On Error GoTo 0

End Sub









Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
split post code (zip code) out of cell that includes full address Concord Excel Discussion (Misc queries) 4 October 15th 09 06:59 PM
Shorten code to apply to all sheets except a few, instead of individually naming them, and later adding to code. Corey Excel Programming 3 December 11th 06 05:14 AM
Protect Sheet with code, but then code will not Paste error. How do i get around this. Please read for explainations.... Corey Excel Programming 4 November 25th 06 04:57 AM
Excel code convert to Access code - Concat & eliminate duplicates italia Excel Programming 1 September 12th 06 12:14 AM


All times are GMT +1. The time now is 06:48 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"