Hi
Any idea why the following (cut down) function gives a "Type Mismatch" error?
I've tried almost everything, in terms of arrays, etc, but I need to pass back 3 values (int, int, double)
"GradeData" is simply a user-defined type containing 2 integers and a double.. - Public Function GroupGradeCount(GroupIdent As Integer, GradeIdent As Integer, ColNum As Integer) As GradeData
-
Dim Res1 As Integer
-
Dim Res2 As Integer
-
Dim Res3 As Double
-
Dim retVar As GradeData
-
Res1 = 19
-
Res2 = 21
-
Res3 = 100 * (Res1 / Res2)
-
retVar.Count = Res1
-
retVar.Total = Res2
-
retVar.Percent = Res3
-
GroupGradeCount = retVar
-
End Function
All suggestions gratefully received.
TIA
Steve
3 2604 NeoPa 32,579
Recognized Expert Moderator MVP
Don't you need to use Set for the last line : - Set GroupGradeCount = retVar
MMcCarthy 14,534
Recognized Expert Moderator MVP
Hi
Any idea why the following (cut down) function gives a "Type Mismatch" error?
I've tried almost everything, in terms of arrays, etc, but I need to pass back 3 values (int, int, double)
"GradeData" is simply a user-defined type containing 2 integers and a double.. - Public Function GroupGradeCount(GroupIdent As Integer, GradeIdent As Integer, ColNum As Integer) As GradeData
-
Dim Res1 As Integer
-
Dim Res2 As Integer
-
Dim Res3 As Double
-
Dim retVar As GradeData
-
Res1 = 19
-
Res2 = 21
-
Res3 = 100 * (Res1 / Res2)
-
retVar.Count = Res1
-
retVar.Total = Res2
-
retVar.Percent = Res3
-
GroupGradeCount = retVar
-
End Function
All suggestions gratefully received.
TIA
Steve
Which line exactly is the code breaking on?
ADezii 8,834
Recognized Expert Expert
Hi
Any idea why the following (cut down) function gives a "Type Mismatch" error?
I've tried almost everything, in terms of arrays, etc, but I need to pass back 3 values (int, int, double)
"GradeData" is simply a user-defined type containing 2 integers and a double.. - Public Function GroupGradeCount(GroupIdent As Integer, GradeIdent As Integer, ColNum As Integer) As GradeData
-
Dim Res1 As Integer
-
Dim Res2 As Integer
-
Dim Res3 As Double
-
Dim retVar As GradeData
-
Res1 = 19
-
Res2 = 21
-
Res3 = 100 * (Res1 / Res2)
-
retVar.Count = Res1
-
retVar.Total = Res2
-
retVar.Percent = Res3
-
GroupGradeCount = retVar
-
End Function
All suggestions gratefully received.
TIA
Steve
If you pass a String Variable to either of the Arguments of the GroupGradeCount Function, you will receive a Type Mismatch Error. Could this be the case? When passed 3 Integers, 2 Integers and a Double will successfully be returned by the Function via the User Defined Type. The code works fine in the below context: - Public Type GradeData
-
Count As Integer
-
Total As Integer
-
Percent As Double
-
End Type
- Dim M As GradeData
-
M = GroupGradeCount(341, 2898, 454)
-
MsgBox M.Count 'Integer
-
MsgBox M.Total 'Integer
-
MsgBox M.Percent 'Double
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Laura |
last post by:
Help. Below is my code. Getting Type mismatch error on
the noted line. I'm trying to send an array (aryNewD)
with 4 columns and x rows to a function to save all the
array info into a SQL Server table via a stored
procedure. Keep getting this error. Any suggestions?
Code:
'ASP:
if blnNewD then
|
by: Gordon |
last post by:
I'm just getting started in ASP and can't seem to figure out how to
run a function in ASP. I get an error of "Line 11 - Type
Mismatch:'myvalidate'.
Line 11 is the Input Button.
Here is my simple page's code, what's wrong???:
<%@LANGUAGE="VBSCRIPT"%>
<%
sub myvalidate()
response.write("ok")
|
by: Mark |
last post by:
Hi - I tried this in VS.Net, and also in the Web Matrix code below: -
but I am getting a type mismatch error.
The sql statement runs perfectly from within the Access Query Designer.
Can anyone verify the syntax, and that my .net code is ok - the type
mismatch is happening at: DataGrid1.DataSource =
myCommand.ExecuteReader(CommandBehavior.CloseConnection)
Thanks in advance,
|
by: amitbadgi |
last post by:
I am getting teh following error while converting an asp application to
asp.net,
Exception Details: System.Runtime.InteropServices.COMException: Type
mismatch.
Source Error:
Line 347: 'response.Write(sql2)
|
by: jg |
last post by:
in VB 2005 the class myClass, I have
Dim someStringArrary() As String
---
sub New()
MyBase.New()
... 'values assigned to elements of someStringArrary
End Sub
......
| |
by: Rehan |
last post by:
Hi there!
Please help me out here. I am an inch away from completing my
assignment.
I am very new to VBA but i have very less time to be efficient at it.
I am getting a type mismatch error when i click the button whose code
is:
|
by: daniel.hedz |
last post by:
I am generating a usercontrol dynamically successfully, but when I try
to find that usercontrol I get a type mismatch. This is what I am
doing:
//Loading my usercontrol
MyWebApp.Folder.Folder.MyUsercontrol myUC =
(MyWebApp.Folder.Folder.MyUsercontrol)
LoadControl("~/Folder/Folder/MyUsercontrol.ascx");
|
by: Davros9 |
last post by:
Trying to get Regular Expressions working.......
----------------
Public Function SepString(InField As String) As String
''seperates on space and comma
Dim RE As New RegExp
Dim Matches As Match
RE.IgnoreCase = True
|
by: psychomad |
last post by:
Please, can someone help me out to solve this error, i've been
searching throughout my codes and yet i didnt succeed in finding the
error!!!!
The Error is:
Server Error in '/' Application.
--------------------------------------------------------------------------------
Data type mismatch in criteria expression.
|
by: Lysander |
last post by:
I have written a query that takes three integers representing day,month and year, forms a date from them and compares this date to the date the record was entered and returns any records where the date is more than 10 months out.
The query runs fine, but I when I put the criteria of >10 I get 'Data Type mismatch' error. The code below is the original query. I have since put all the datediff bit in code, with all variables declared as date,...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |