Solved

Add a month to the date entered in a msflexgrid i get type mismatch

Posted on 2013-10-22
11
413 Views
Last Modified: 2013-10-22
I get error: Type mismatch
How can i write this:
Dim LastMonth As Date

LastMonth = gridHouse.TextMatrix(gridHouse.Rows - 1, 1)

In the msflexgrid date is like this:May/2013
0
Comment
Question by:isnoend2001
  • 4
  • 3
  • 3
  • +1
11 Comments
 
LVL 45

Assisted Solution

by:aikimark
aikimark earned 300 total points
ID: 39592662
Try this.  You need to cast the text as a date data type.
LastMonth = CDate(gridHouse.TextMatrix(gridHouse.Rows - 1, 1))

Open in new window

0
 

Author Comment

by:isnoend2001
ID: 39592734
Thanks : aikimark, but still the same error: error13 type mismatch
0
 
LVL 45

Assisted Solution

by:aikimark
aikimark earned 300 total points
ID: 39592760
please verify the contents of that cell
0
 

Author Comment

by:isnoend2001
ID: 39592792
already did just to be sure
 MsgBox gridHouse.TextMatrix(gridHouse.Rows - 1, 1)
returns Aug\2014
0
 
LVL 76

Assisted Solution

by:GrahamSkan
GrahamSkan earned 100 total points
ID: 39592822
"Aug\2014" can't be converted to a date.

Try:
LastMonth = Replace(gridHouse.TextMatrix(gridHouse.Rows - 1, 1), "\","")

Open in new window

0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 45

Assisted Solution

by:Martin Liss
Martin Liss earned 100 total points
ID: 39592825
Which is it
In the msflexgrid date is like this:May/2013

or

returns Aug\2014

Note the direction of the slashes.
0
 
LVL 76

Assisted Solution

by:GrahamSkan
GrahamSkan earned 100 total points
ID: 39592834
I see that a space got lost in my code (third Replace argument)

It should have been:
LastMonth = Replace(gridHouse.TextMatrix(gridHouse.Rows - 1, 1), "\"," ")
0
 
LVL 45

Accepted Solution

by:
aikimark earned 300 total points
ID: 39592847
If it is a backslash, instead of the front slash you originally posted, you can do something similar to what GrahamSkan suggested and change the backslash character.
LastMonth = CDate(Replace(gridHouse.TextMatrix(gridHouse.Rows - 1, 1), "\","/"))

Open in new window

0
 

Author Comment

by:isnoend2001
ID: 39592852
backslash (\)
LastMonth = Replace(gridHouse.TextMatrix(gridHouse.Rows - 1, 1), "\", "") returns the same error
see grid attached
mismatch-error.jpg
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 39592862
Sorry. My first comment had a typo in the code. The second version should work.
0
 

Author Closing Comment

by:isnoend2001
ID: 39592872
Thanks that fixes it
LastMonth = CDate(Replace(gridHouse.TextMatrix(gridHouse.Rows - 1, 1), "\","/"))
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now