Notices

Water Fountain General Chit/Chat

Reply
 
LinkBack Thread Tools
Old 08-13-03, 03:36 AM   #1 (permalink)
Aximsite Prospect
 
Join Date: Jul 2003
Location: East Anglia ,UK
Posts: 12
Thanked 0 Times in 0 Posts
Question Using the Left/right string function

I have been trying to call the function left(string,n) in a small evb program but keep getting an error message when running the program which states that 'object is not a collection.' If I remove the parsing part of the code the string is returned okay. I have applied the code the same way as I did in visual basic and the help page indicates that the left function is available in EVB so what am I doing wrong. Can anybody help?
birdseye is offline   Reply With Quote
Sponsor Ads
Old 08-13-03, 08:34 AM   #2 (permalink)
papajackow
Guest
 
Posts: n/a
Re: Using the Left/right string function

Quote:
Originally posted by birdseye
I have been trying to call the function left(string,n) in a small evb program but keep getting an error message when running the program which states that 'object is not a collection.' If I remove the parsing part of the code the string is returned okay. I have applied the code the same way as I did in visual basic and the help page indicates that the left function is available in EVB so what am I doing wrong. Can anybody help?
If you could post some of the relevant code I'll see what I can do. :)
  Reply With Quote
Old 08-13-03, 08:37 AM   #3 (permalink)
Aximsite Elite
 
silentknight's Avatar
Addicted Member
 
Join Date: Jan 2003
Location: GR, Michigan
Posts: 3,380
Device: Nokia 6255i
Carrier: Alltel
Thanked 1 Time in 1 Post

Awards Showcase
Aximsite Active Silver Member Aximsite Veteran Staff Moderator Medal 
Total Awards: 3

yes, post some code!..

I have had no problems using this function.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


My recent reviews:

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
silentknight is offline   Reply With Quote
Old 08-13-03, 08:57 AM   #4 (permalink)
Aximsite Minor League
 
Ohayden's Avatar
Member
 
Join Date: Jun 2003
Location: http://www.ATechware.com
Posts: 187
Thanked 0 Times in 0 Posts
Has nothing to do with your code... it's a problem with Microsoft's code. There is a well known bug in eVB where the left function will ONLY work in a module and not a form. You have two solutions:

Use the MID function instead of left.

-or-

Create a public function in a module call MyLeft and just wrap the left function.

Here is the knowledge base article explaining the issue:

http://support.microsoft.com/default...b;en-us;180455
__________________
Ohayden,

Axim X30

Pocket PC Software:

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Ohayden is offline   Reply With Quote
Old 08-17-03, 04:00 AM   #5 (permalink)
Aximsite Prospect
 
Join Date: Jul 2003
Location: East Anglia ,UK
Posts: 12
Thanked 0 Times in 0 Posts
On a form I have put a text box , 2 command buttons and 2 labels.
On running the code below, label2 will correctly show the contents of Text1 after clicking on command1, but on clicking on command2 the error Report
‘an error was encountered when running this program object is not a collection’ is shown

Private Sub Command1_Click()
Dim ml
ml=Cstr(text1)
Label2 = ml

End Sub

Private Sub Command2_Click()
Dim mls
ml=Cstr(text1)
Label3 = Left(ml,3)
End Sub
birdseye is offline   Reply With Quote
Old 08-17-03, 04:03 AM   #6 (permalink)
Aximsite Prospect
 
Join Date: Jul 2003
Location: East Anglia ,UK
Posts: 12
Thanked 0 Times in 0 Posts
Further to the last post I made a small typing error, the code I put into command2 was as follow

Private Sub Command2_Click()
Dim mls
mls=Cstr(text1)
Label3 = Left(mls,3)
End Sub
birdseye is offline   Reply With Quote
Old 08-17-03, 01:57 PM   #7 (permalink)
Aximsite Minor League
 
Ohayden's Avatar
Member
 
Join Date: Jun 2003
Location: http://www.ATechware.com
Posts: 187
Thanked 0 Times in 0 Posts
OMG, your answer is above in my previous post! As I said, this is a KNOWN issue. It's been known for a loooong time and the solution is to NOT use LEFT and to use MID instead. LEFT conflicts with the LEFT of a forms property, although LEFT is fine in a module.

Here is your code fixed:

Code:
Private Sub Command2_Click()
     Dim mls

     mls = Cstr(text1)
     Label3 = Mid(mls, 1, 3)
End Sub
__________________
Ohayden,

Axim X30

Pocket PC Software:

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by Ohayden; 08-17-03 at 02:00 PM.
Ohayden is offline   Reply With Quote
Old 08-18-03, 06:03 AM   #8 (permalink)
Aximsite Prospect
 
Join Date: Jul 2003
Location: East Anglia ,UK
Posts: 12
Thanked 0 Times in 0 Posts
Thanks for your help
birdseye is offline   Reply With Quote
Old 11-12-03, 11:20 AM   #9 (permalink)
Aximsite Prospect
 
Join Date: Nov 2003
Posts: 3
Thanked 0 Times in 0 Posts
I am calling the funciton below. When I use it I get an error about using the 'Mid' function. This code should run just fine. I have tried it in both a form and a module.

Public Function ChkQty(vQty As String) As Boolean
Dim X As Long
Dim sQty As String


'validate a numeric value

For X = 0 To Len(vQty) - 1

sQty = Mid(vQty, X, 1)

If Asc(vQty) >= 48 And Asc(vQty) <= 57 Then
'no alpha characters
Else
MsgBox "QTY can contain numeric values only!", vbInformation, "Remote Invoice"
ChkQty = False
Exit Function
End If

Next X


ChkQty = True

End Function
exbox is offline   Reply With Quote
Old 11-12-03, 11:29 AM   #10 (permalink)
Aximsite Minor League
 
Ohayden's Avatar
Member
 
Join Date: Jun 2003
Location: http://www.ATechware.com
Posts: 187
Thanked 0 Times in 0 Posts
exbox,

I can tell you come from a "C" background ;). eVB is not zero based and strings (TCHARS) are one based. In your "for loop" you're starting at zero, you need to start at one as follows:

I optimized your function for you plus fixed a bug. You set sQty but used vQty instead :).

Code:
Public Function ChkQty(vQty As String) As Boolean
Dim X As Long
Dim sQty As String

     'validate a numeric value

     ChkQty = True ' DEFAULT TO TRUE
     For X = 1 To Len(vQty)
          sQty = Mid(vQty, X, 1)

          If Asc(sQty) < 48 Or Asc(sQty) > 57 Then
               MsgBox "QTY can contain numeric values only!", vbInformation, "Remote Invoice"
               ChkQty = False
               Exit For
          End If
     Next X
End Function
Regards,
__________________
Ohayden,

Axim X30

Pocket PC Software:

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Last edited by Ohayden; 11-12-03 at 11:34 AM.
Ohayden is offline   Reply With Quote
Old 11-12-03, 12:20 PM   #11 (permalink)
Aximsite Prospect
 
Join Date: Nov 2003
Posts: 3
Thanked 0 Times in 0 Posts
Excellent, that did the trick.

Thanks Much!
exbox is offline   Reply With Quote
Old 11-12-03, 12:22 PM   #12 (permalink)
Aximsite Minor League
 
Ohayden's Avatar
Member
 
Join Date: Jun 2003
Location: http://www.ATechware.com
Posts: 187
Thanked 0 Times in 0 Posts
Not a problem. Glad I could help :).
__________________
Ohayden,

Axim X30

Pocket PC Software:

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Ohayden is offline   Reply With Quote
Old 11-21-03, 02:37 PM   #13 (permalink)
Aximsite Prospect
 
Join Date: Nov 2003
Posts: 3
Thanked 0 Times in 0 Posts
Can someone tell me why this recordset won't open:
Rs.Source = "SELECT InvoiceNo, CustCode, CusName FROM Invoices WHERE Void = 0 ORDER BY InvoiceNo ASC"
Rs.CursorType = adOpenForwardOnly
Rs.ActiveConnection = oConnection
Rs.Open

AND this one will:
Rs.Source = "SELECT InvoiceNo, CustCode, CusName FROM Invoices ORDER BY InvoiceNo ASC"
Rs.CursorType = adOpenForwardOnly
Rs.ActiveConnection = oConnection
Rs.Open

The difference is the Where clause VOID = 0
Void is a Yes/No field.
exbox is offline   Reply With Quote
Reply

Sponsor Ads

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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



All times are GMT -5. The time now is 01:51 AM.
Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0
Copyright © 2003-09 LeckMedia, LLC