Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > Array type mismatch error


Reply
 
Thread Tools Display Modes
  #1  
Old 10-01-2003, 01:38 AM
dragon4spy dragon4spy is offline
Banned
 
Join Date: Jul 2003
Location: Angkor, Cambodia
Posts: 143
Question Array type mismatch error


Hi! i've tried to pass byte array to a argument (variant array) of a sub, but then i got a type mismatch error. please help me, i don't want to duplicate the sub for each type. To make sure you can understand my english, i include the example for you. Please help me...

Code:
Sub Main() Dim a() as Byte Test a() '<------- Type mismatch error End Sub Sub Test(Arr()) 'Codes End Sub
Reply With Quote
  #2  
Old 10-01-2003, 02:07 AM
Flyguy's Avatar
Flyguy Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 18,885
Default

You are passing a byte array not a variant.
You should declare your function like this:
Code:
Private Sub Test(Arr() As Byte) End Sub
Reply With Quote
  #3  
Old 10-01-2003, 02:07 AM
gundavarapu's Avatar
gundavarapu gundavarapu is offline
Senior Contributor
 
Join Date: Aug 2002
Location: In loved one's heart
Posts: 929
Default

try this...
Code:
Sub Main() Dim a() As variant Test a '<------- now it should be ok End Sub Sub Test(Arr() as variant) 'Codes End Sub
__________________
Regards,
Sidhu

When you do not get the expected result, change your programming language.
Reply With Quote
  #4  
Old 10-01-2003, 02:11 AM
dragon4spy dragon4spy is offline
Banned
 
Join Date: Jul 2003
Location: Angkor, Cambodia
Posts: 143
Default

Quote:
Originally Posted by Flyguy
You are passing a byte array not a variant.
You should declare your function like this:
Code:
Private Sub Test(Arr() As Byte) End Sub



But i want only one sub/function can handle any array type. no duplications. Thanks anyway ;-)
Reply With Quote
  #5  
Old 10-01-2003, 02:12 AM
Flyguy's Avatar
Flyguy Flyguy is offline
Lost Soul

Super Moderator
* Guru *
 
Join Date: May 2001
Location: Vorlon
Posts: 18,885
Default

If you want this strange way of coding then make all variables/arrays Variants too. No need for using strong data types.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Array and String Functions rhawke General 5 07-10-2003 02:33 AM
Type mismatch error Purdue2379 General 5 06-17-2003 12:17 PM
Problem with Direct Input and Direct Sound Waxycat Miscellaneous Languages 15 06-06-2003 11:03 AM
Simulated Inheritance - Array of UserDefinedObjects - type mismatch error Kozimann General 3 05-28-2002 10:18 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->