473,763 Members | 7,719 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Receiving "Type Mismatch Error"

2 New Member
I am using VB 6 in order to clear a listbox (lststuff) containing material entered by the user via input boxes. I am trying to utilize a command button which will clear the list for the user. When testing the program, as soon as i click on the command button I receive a "Type mismatch" error. How can I solve this?

This is the code I am using:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdclear_Click(Index As Integer)
  2.     Dim warning As String
  3.     warning = InputBox("Caution! This will DELETE your ENTIRE list. Do you Still wish to Continue", "Be Careful")
  4.     If warning Is "Yes" Or "Y" Then
  5.         lstStuff.Clear
  6.     ElseIf warning Is "No" Or "N" Then
  7.         warning = MsgBox("Your list was not cleared", , "List not Cleared")
  8.     Else
  9.         warning = MsgBox("Response not recognized. Please Type 'Yes' Or 'No'", , "Input Error")
  10.     End If
  11. End Sub 
Dec 28 '07 #1
3 2523
creative1
274 Contributor
Try this

If warning = "Yes" Or warning ="Y" Then
Dec 29 '07 #2
VijaySofist
107 New Member
I am using VB 6 in order to clear a listbox (lststuff) containing material entered by the user via input boxes. I am trying to utilize a command button which will clear the list for the user. When testing the program, as soon as i click on the command button i receive a "Type mismatch" error. How can I solve this?

this is the code i am using:
Expand|Select|Wrap|Line Numbers
  1.  Private Sub cmdclear_Click(Index As Integer)
  2.     Dim warning As String
  3.     warning = InputBox("Caution! This will DELETE your ENTIRE list. Do you Still wish to Continue", "Be Careful")
  4.         If warning Is "Yes" Or "Y" Then
  5.             lstStuff.Clear
  6.         ElseIf warning Is "No" Or "N" Then
  7.             warning = MsgBox("Your list was not cleared", , "List not Cleared")
  8.         Else
  9.             warning = MsgBox("Response not recognized. Please Type 'Yes' Or 'No'", , "Input Error")
  10.         End If
  11. End Sub 
Hi!

In your coding, Why can't you use a MsgBox instead of InputBox

Try the foolowing code in your program
Expand|Select|Wrap|Line Numbers
  1.  Private Sub cmdclear_Click(Index As Integer)
  2.     Dim warning As String
  3.     warning = MsgBox("Caution! This will DELETE your ENTIRE list. Do you Still wish to Continue", vbInformation+vbYesNo,"Be Careful")
  4.         If warning =vbYes Then
  5.             lstStuff.Clear
  6.         Else
  7.             warning = MsgBox("Your list was not cleared", , "List not Cleared")
  8.         End If
  9. End Sub
All The Best

With Regards
Vijay. R
Dec 29 '07 #3
Killer42
8,435 Recognized Expert Expert
bxscikid, in case you missed it the point creative1 was making is that Is is not the correct comparison operator. You should use =.
Dec 29 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
2801
by: dmgauntt2002 | last post by:
I have some javascript ASP code that sets the expiry date on a cookie to five years from now. The code worked until today, when I got the following error message: Microsoft JScript runtime (0x800A000D) Type mismatch The code was var expiryDate=new Date();
2
1847
by: Andrew Proctor | last post by:
Hello This is not a big problem, but I was hoping someone a bit more knowlegable than I could explain something to me. I have a simple function behind a form which writes changed values to a table for tracking purposes : Public Sub RecordChanges() Dim strInsertValue As String strInsertValue = "INSERT INTO
1
3077
by: ApexData | last post by:
Access2k I WAS getting the following error when using the MID function: Run Time Error '13' Type Mismatch I have a new single form, unbound with 1-button on it that uses the following code: Private Sub Command0_Click() MsgBox MID("ABCDEFG", 1, 1)
5
4411
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
3
17180
by: klaritydefect | last post by:
Hi, I am receving the following error when I run my application (build on C ++ code) Program received signal SIGSEGV, Segmentation fault si_code: 1 - SEGV_MAPERR - Address not mapped to object. I debug using gdb to find the error and located the position where it is throwing an error
17
5070
imrosie
by: imrosie | last post by:
I've tried this string to Sum up payments, moving brackets and paren's different ways, I still get error 'type mismatch'....not sure why. Can anyone point me in the right direction?? thanks LineTotal: Sum(CLng(**(1-)*100)/100) Rosie
10
4582
by: dstorms | last post by:
Hi, I'm trying to create a button on a form that: 1. Takes the ComputerID from the form linked to Table 1, 2. Checks Table 2 for a matching ComputerID, and 3. Opens the query qryEditData, and 4. If no match can be found, adds a new record in Table 2 and enters the ComputerID automatcially. The goal is to create a new record in Table 2 when a new record is created in table 1 and have the ComputerID fields match with a 1-to-1...
3
6794
by: martin DH | last post by:
I would definitely appreciate any help with this problem as soon as possible. Thanks! I have a report that should display the results of a query based on two tables (tblClient and tblResult, linked by ClientID). When trying to open the report I receive the following error: "Data Type Mismatch in Criteria Expression" The report worked before, so as an experiment I created a new table with a structure identical to tblResult (so I...
2
5593
DonRayner
by: DonRayner | last post by:
This one has me stumped. I'm getting a "Type Mismatch" error on one of my forms when it's being opened. It's hapening before the forms "On Open" event, I stuck a msgbox in there to check and I'm getting the error before it opens. The line of code that calls the form from another form is. DoCmd.OpenForm "NonConformanceAdd",,,,acFormAdd,acDialog I get the error, click ok, then the form opens and works exactly how it's supposed to. I even...
0
9563
marktang
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...
0
9997
jinu1996
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...
1
9937
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8821
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7366
isladogs
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...
0
6642
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();...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
3522
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2793
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.