Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Excel Sheet With Macro Type Mismatch


Dear All,
I open a sheet which actually has macro and also filename.xls and filename.xla
Now when i say
Msgbox excel.Application.Version 'it does it fine
Msgbox excel.activesheet.name 'it works fine
But when i say
Set Oworksheet = excel.activesheet ' it gives me typemismatch error #13
also the same error for the following
For Each sht In excel.ActiveWorkbook.Sheets ' gives error on this line
MsgBox sht.Name
Next sht

Any inputs?
Thanks a lot

snehal




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Excel With Macro Type Mismatch #13
Dear All,
I open a sheet which actually has macro and also filename.xls and filename.xla
Now when i say
Msgbox excel.Application.Version 'it does it fine
Msgbox excel.activesheet.name 'it works fine
But when i say
Set Oworksheet = excel.activesheet ' it gives me typemismatch error #13
also the same error for the following
For Each sht In excel.ActiveWorkbook.Sheets ' gives error on this line
MsgBox sht.Name
Next sht


Also sht and oworksheet are dim as excel.worksheet
Any inputs?
Thanks a lot
snehal

VB6.0: Find Excel Sheet With Macro
I am trying to build a small Visual Basic application (VB6.0) that will loop through a folder and pick out all the Excel files.

My question is--How can I programmatically tell if a particular Excel file contain Macro?

Please help me out.

Thanks in advance.

Open Another Excel Sheet In A Macro
Is it possible to open another excel sheet in a macro?
I want to copy data from one excel sheet to another

I tried this in abc.xls but it errors out
Code:
 Private Sub comp()
 Dim xlTmp As Excel.Application
  
  Set xlTmp = New Excel.Application
  xlTmp.Workbooks.Open "xyz.xls"
 
 End Sub

Please help

Vb Macro Needed To Split Excel Sheet
--------------------------------------------------------------------------------

Hi All,

I Need A Vb Macro Script To Make Multiple Copies Of Microsoft Excel Sheet After 65 Rows Are Exceeded. Since Am Using Excel It Limits Onl;y 65k Rows.

Can U Please Help Me With Code.


Vb Macro To Break Excel Sheet After It Exceeds 65k Rows
Million Thanks In Advance



Edit by Moderator:
Please post Excel questions, in the Excel forum.

Thank you.

Macro To Retrieve Set Of Data From Excel Sheet
I had a requirement :
There are some column values in excel sheet containing some date columns and other data running .But the requirement is to retrieve the whole set of column values or data which lies within the latest week,ie,if today is 26th july then i need to get all the data from 19th july to 26th july.The present date must be taken from the system date. And there is one more constraint ,the date column values are in the form of 'dd month-name yyyy' eg:'15 march 2006'.Am in urgent need of the script, as am newbie to vb


Here is the example:

Theres a sheet with values in columns A,B,C where C col contains date values like '15 march 2006','06 august 2007' and so on.I need a macro to retrieve only week days data from present day.With respect to the example mentioned above the data that i require is the A,B,C column values for '06 august 2007' and any other lying within the week day values.I was just stuck up in creating the macro as am new to vb. I think this suffices you.Please help me in forming the macro ...its really very urgent .

The main prob where i was stuck is:

getting the latest week's data , ie, system date-7 days
and also the conversion of date format from the source.the complete script is more helpful.

Excel Macro Copy/paste To New Sheet, Next Row
A little background, I've got an excel spreadsheet that gets updated everyday. If there are no problems at the facility, there is nothing to paste to the other worksheet. I just need to record problems at the facility on to another worksheet. I could do it by date, but I would have big blank areas on the sheet because we only have problems a couple times a month. This spreadsheet captures a years worth of operational data.

here's what I've got so far, it may not be pretty but it works (except for the part in bold that I need to paste to the next row)

Quote:

Msg = "Comments are necessary if there was Planned or Unplanned Downtime" ' Define message.
Style = vbOKCancel + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "MsgBox Demonstration" ' Define title.
Response = MsgBox(Msg, Style, Title)
If Response = vbYes Then ' User chose Yes' button.
MyString = "Yes" ' Perform some action.
Sheets("Time").Select
Range("l21:z21").Select
Selection.Copy
Range("l22").Select
Selection.Offset(Range("k21"), 0).Select
Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
End If

Sheets("Sheet2").Select
Range("I13:K17").Select
If Range("J37") > "0" Then
Msg = "Do you wish to submit these downtime hours?" ' Define message.
Style = vbYesNo + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "MsgBox Demonstration" ' Define title.
Response = MsgBox(Msg, Style, Title)
Else: End If

If Response = vbYes Then ' User chose Yes' button.
MyString = "Yes" ' Perform some action.
Sheets("Sheet2").Select
Range("M13").Select

If Range("M13") = "" Then

Msg = "You must explain the reason for the downtime the Comments area!" ' Define message.
Style = vbOKCancel + vbCritical + vbDefaultButton2 ' Define buttons.
Title = "MsgBox Demonstration" ' Define title.
Response = MsgBox(Msg, Style, Title)
Else: Sheets("Sheet2").Select
Range("M13").Select
Selection.Copy
Sheets("Results").Select
Range("B40").Select
Selection.Offset(1, 0).Select

Selection.PasteSpecial Paste:=xlValues, Operation:=xlNone, SkipBlanks:= _
False, Transpose:=False
Sheets("Sheet2").Select
Range("L2").Select
Selection.Copy
Sheets("Results").Select
Range("A40").Select
Selection.Offset(1, 0).Select
Selection.PasteSpecial Paste:=xlValues, SkipBlanks:= _
False, Transpose:=False
Sheets("Sheet2").Select
If Response = vbOK Then ' User chose OK' button.
MyString = "Yes" ' Perform some action.
Sheets("Sheet2").Select


I need to start @ B40 and each time there is something in M13 (and sum J37 > 0) it needs to past to B41, then the next time B42.

I hope this makes sense!
thanks!
...Brady

VBA Excel To Access - Type Mismatch Error
Hi,

Unique Records is flagging up an error in VBE saying "type mismatch error" ALTHOUGH it does post the data to ACCESS.
(and yess, the excel cell format is number and the access database field is also a long integer number, so its not as if Im sending number to text)....

How do I either:

1. Suppress the darn errors (since it actually does send the data from Excel to Access
2. Fix this error

    r = 2 ' the start row in the worksheet
    Do While Len(Range("A" & r).Formula) > 0
    ' repeat until first empty cell in column A
     With rs
            .AddNew ' create a new record
            ' add values to each field in the record
            .Fields("SERVICE_PROVIDER") = Range("A" & r).Value
            .Fields("SITE NAME") = Range("B" & r).Value
            .Fields("UNIQUE ID") = Range("C" & r).Value

Thanks

Excel: Writing From Macro Form To Text Box On Sheet
There are two boxes that seem like they would work for me. I just need to automatically fill in a text box from a form. There is a label command available on the Forms toolbar and a Text Box command on the Drawing toolbar. From my limited experience with VB, it seems like I somehow need a label for these boxes. I need to have a label so I can send a value to the right place. Can someone help me out? I couldn't find any help by searching this forum.

There's also an Edit Box command that's not enabled on my toolbar.

Help With Macro To Copy Excel Sheet W/o Blank Lines
Ok, I'm working with Excel and tryiny to creat a macro to copy all data from one sheet, but skip blank spaces between them. I'm trying this formula, but its not working... any suggestions?

Private Sub CommandButton1_Click()

With Sheets("Sheet10")
.Cells.ClearContents

.Cells(1, 1).Value = "LocationID"
.Cells(1, 2).Value = "Provider"
.Cells(1, 3).Value = "Amount"
.Cells(1, 4).Value = "Pin"
.Cells(1, 5).Value = "Radiant CardID"
.Cells(1, 6).Value = "BatchID"
.Cells(1, 7).Value = "Date Imported"
.Cells(1, 8).Value = "Date Sold"
.Cells(1, 9).Value = "Comments"
.Cells(1, 10).Value = "When used"
.Cells(1, 11).Value = "Location Percentage"
.Cells(1, 12).Value = "Credit Amount"
.Cells(1, 13).Value = "CardID"
.Cells(1, 14).Value = "LocationID"
.Cells(1, 15).Value = "POSCardTypeID"
.Cells(1, 16).Value = "ProviderID"
.Cells(1, 17).Value = "RegionID"
.Cells(1, 18).Value = "Pin"
.Cells(1, 19).Value = "Denomination"
.Cells(1, 20).Value = "DateAdded"
For Each c In Sheets("New pins convert").Columns("A:A").SpecialCells(xlCellTypeConstants, 3)
If NotFound(c.Value, "New pins convert") Then
NxRw = .Cells(65536, 1).End(xlUp).Row + 1
.Cells(NxRw, 1).Value = c.Value
.Cells(NxRw, 2).Value = c.Value
.Cells(NxRw, 3).Value = c.Value
.Cells(NxRw, 4).Value = c.Value
.Cells(NxRw, 5).Value = c.Value
.Cells(NxRw, 6).Value = c.Value
.Cells(NxRw, 7).Value = c.Value
.Cells(NxRw, 8).Value = c.Value
.Cells(NxRw, 9).Value = c.Value
.Cells(NxRw, 10).Value = c.Value
.Cells(NxRw, 11).Value = c.Value
.Cells(NxRw, 12).Value = c.Value
.Cells(NxRw, 13).Value = c.Value
.Cells(NxRw, 14).Value = c.Value
.Cells(NxRw, 15).Value = c.Value
.Cells(NxRw, 16).Value = c.Value
.Cells(NxRw, 17).Value = c.Value
.Cells(NxRw, 18).Value = c.Value
.Cells(NxRw, 19).Value = c.Value
.Cells(NxRw, 20).Value = c.Value
End If
Next c

End With
End Sub

Public Function NotFound(CellValue, SheetToSearch) As Boolean
With Worksheets(SheetToSearch).Range("A:A")
Set c = .Find(CellValue, LookIn:=xlValues)
If Not c Is Nothing Then
NotFound = False
Else
NotFound = True
End If
End With
End Function

Excel Macro To Insert Formula For Variable File First Sheet
I built a macro that loops through all the file names in a folder.
I wanted to then check in cell c7 of each file to see what the content was with out opening the file. I was unable to accomplish this, so I went to plan 2. I want to place a formula on a spread sheet that will bring in the number from cell c7 on the first worksheet. The reason I went this rout is time. When you open and close files the macro takes too much time to run. My formula below works as long as the first sheet in each workbook is sheet 1 the problem is most are not they vary in name. How can I replace sheet1 in my code to pull any 1st worksheet name?

Formula1 = "='H:Mo[" & MyFile & "]Sheet1'!C7"

Macro W/ Embedded Excel Sheet: Error Script Out Of Range
Due to my worksheet's columns being aligned to where I don't have enough space to code in some new information I had to do the following:
MS Word: InsertObjectMS Excel WorksheetCopy it over to Excel and use Past SpecialExcel Worksheet Object
Next, after inputting the =sumif formulas, I created a Forms Button to have it execute the vb script. What needs to happen is for the formulas in the embedded excel sheet to update I have to open & close the embedded sheet. What I want is for the button to run that procedure automatically. When I execute that script it gives me the error "subscript out of range". The script is the following and in debug mode it highlights the 2nd row:

ActiveSheet.Shapes("Object 14").Select
Windows("Worksheet in Service Count Sheet").Visible = True
Selection.Verb Verb:=xlPrimary
ActiveWindow.Close

What can I do to resolve this? I have included a copy of the test sheet.

Thanks.
Troy

Type Mismatch Using Cells.Find From Existing Instance Of Excel
Hi folks,

In the following code:

Code:
' get current instance of excel
Set gXlApp = GetObject(, "excel.application")
If Err.Number <> 0 Then
' excel not open, then create an instance
Err.Clear
Set gXlApp = CreateObject("excel.application")
If Err.Number <> 0 Then
' excel not installed?
Err.Clear
Exit Sub
End If
End If

gXlApp.Visible = True

If gXlApp.Workbooks.count > 0 Then
On Error GoTo OpenInstead
gXlApp.Workbooks("Test.XLS").Activate
Else
OpenInstead:
gXlApp.Workbooks.Open "Test.XLS"
End If

AppActivate gXlApp.ActiveWindow.Caption
Set curSheet = gXlApp.ActiveSheet
curRow = 2

With curSheet
gXlApp.Cells(1, 1).Activate

'
'
' Here's the Problem Line:
'

gXlApp.Cells.Find(What:=curTitle, after:=ActiveCell, LookIn:=xlFormulas, Lookat _
:=xlWhole, SearchOrder:=xlByColumns, SearchDirection:=xlNext, MatchCase:= _
False, SearchFormat:=False).Activate
End With
The problem line above is fine *if Excel was not already open* (i.e., if it had to make a new instance of it, at top). If it was already open, I get a Type Mismatch error. Any ideas?

Thanks!
-Pete

How To Create A Macro To Copy Information In One Sheet To Another Sheet.
Hi All,
I was wondering how I can create a Macro to copy information that is on Sheet1 to SHeet2. The kink is that it only should copy the information in Column A when for example column C has a cell in it saying "YES". Please let me know at your earliest convience.

Thank You.
Mark

Bypass "Enable Macro ?" Warning In Excel Sheet Embedded In VB With OLE
Hi all,

I am embedding an excel sheet using OLE in my VB application. I have everything what i need but when i activate my workbook in the application, it gives me those security warning "Do you want to enable macros ?" and also it shows me the dialog of "Do you want to save changes to [my excel sheet] ?" and then again the security warning.

As you can imagine i am getting tired of these dialog and i do know that if in OLE the OLE1.object will return me the embedded workbook. So is there anything i can do to bypass these dialogs ?

Thanks.

XML Parsing Into Excel - "type Mismatch" Error
I'm trying to extract some data from a remote XML file and stick it into a cell in my worksheet.

Here is how I've been able to get the whole XML document:

Sub Login()
Dim xmlhttp
Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
strXML = "<xmlrequest requestOp='getLogin'><membershipNumber>123456789</membershipNumber><password>password1</password></xmlrequest>"
Call xmlhttp.Open("POST", "https://www.tradesports.com/xml/handler.jsp", False)
Call xmlhttp.setRequestHeader("Content-Type", "text/xml")
Call xmlhttp.send(strXML)
Dim xmlDoc
Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.async = False
Range("A1").Value = xmlhttp.responsetext
End Sub

The problem is that I can't seem to parse the XML to get just one bit of data. For instance, the dummy POST above would return <sessionData>ANONYMOUS</sessionData>. I'd like to get just "ANONYMOUS" into a cell.

I've tried replacing the last line of the Sub above with:

xmldoc.loadxml(xmlhttp.responsexml)
Range("A2").Value = xmldoc.documentelement.getAttribute("sessionData")

But I get "type mismatch" on the line "xmldoc.loadxml(xmlhttp.responsexml)"

Anyone see my error?

Importing Data From One Closed Excel Sheet Into Another Open Excel Sheet
Dear all,
   I am VBA newbie ... I need your help in importing the data froma closed excel document into another excel document.

Please help.
Cheers
Vivek

Type Mismatch -Çan't Figuew Out The Mismatch
why do I get "type mismatch" on the red line?


Code:
Public Sub UpdateNDO() 'Load Institute Database into memory
Dim PosTilde(100) ' As Integer
Dim NDONr As Long
Dim tel5 As Integer
Dim teller5 As Integer
Dim regel5 As String
Dim t As Integer
Dim lengte As String
Dim clmx As ColumnHeader
Dim itmX As ListItem
t = 0
tel5 = 0
teller5 = 0

ChDrive ("K") 'ChDrive (DrvLetter)
ChDir ("PERSOONLIJKE WERKMAPPENJAIMYVBPED SQL") 'ChDir (Pad)
SetAttr "NDOdata.dbf", vbNormal
FileCopy "NDOdata.dbf", "NDOdata.tmp" 'creates a backup-file before each session
NDONr = 0
Open "NDOdata.dbf" For Input As #28 'Open "KACis.dbf" For Input As #1

Do While Not EOF(28)
Line Input #28, regel5
tel5 = 1
For teller5 = 1 To Len(regel5)
If Mid(regel5, teller5, 1) = "~" Then
PosTilde(tel5) = teller5
tel5 = tel5 + 1
End If
Next teller5
NDONr = NDONr + 1
recNDO(NDONr).UN = Mid(regel5, 1, PosTilde(1) - 1)
If recNDO(NDONr).UN > NextUN - 1 Then
NextUN = recNDO(NDONr).UN + 1
End If
recNDO(NDONr).NDONr = Mid(regel5, PosTilde(1) + 1, PosTilde(2) - PosTilde(1) - 1)
recNDO(NDONr).ThicknessGroup = Mid(regel5, PosTilde(2) + 1, PosTilde(3) - PosTilde(2) - 1)
recNDO(NDONr).Counter = Mid(regel5, PosTilde(3) + 1)

Loop
Close #28
SetAttr "NDOdata.dbf", vbReadOnly
NrNDO = NDONr

frmNDO.LVNDO.ListItems.Clear
frmNDO.LVNDO.ColumnHeaders.Clear
[color=Red] Set clmx = frmNDO.LVNDO.ColumnHeaders.Add(, , "Nr.", 1700, 0)[/color]
Set clmx = frmNDO.LVNDO.ColumnHeaders.Add(, , "NDO Nr.", 1700, 0)
Set clmx = frmNDO.LVNDO.ColumnHeaders.Add(, , "Dikte Gr.", 1500, 0)
Set clmx = frmNDO.LVNDO.ColumnHeaders.Add(, , "Counter", 1500, 0)


For t = 1 To NrNDO
lengte = Len(Str(recNDO(t).UN))
Select Case lengte
Case 1: Set itmX = frmNDO.LVNDO.ListItems.Add(, , "00000" & recNDO(t).UN)
Case 2: Set itmX = frmNDO.LVNDO.ListItems.Add(, , "0000" & recNDO(t).UN)
Case 3: Set itmX = frmNDO.LVNDO.ListItems.Add(, , "000" & recNDO(t).UN)
Case 4: Set itmX = frmNDO.LVNDO.ListItems.Add(, , "00" & recNDO(t).UN)
Case 5: Set itmX = frmNDO.LVNDO.ListItems.Add(, , "0" & recNDO(t).UN)
End Select
itmX.SubItems(1) = recNDO(t).NDONr
itmX.SubItems(2) = recNDO(t).ThicknessGroup
itmX.SubItems(3) = recNDO(t).Counter
Next t

frmNDO.LVNDO.View = lvwReport
frmNDO.LVNDO.SortKey = 3 '2
frmNDO.LVNDO.Sorted = True
addsave = False
Save = True

' frmNDO.LVNDO.SortKey = header '.Index - 1 'sort by UN -unique number- this way the order of found results is conform the order in the ASCII database file
frmNDO.LVNDO.SortOrder = lvwAscending
End Sub

(sorry I forgot teh tags and on of my carriage returns was off)

A Sheet's Number Or A Sheet's Name Using A Macro
Hi,
I have searched for a way to let a macro copy a sheet and move it to (before) a special sheet - let's call it "Special".

The code Sheets("Origin").Copy Before:=Sheets("Special") worked fine for some days but not any longer.

When a macro records this it writes
Sheets("Origin").Copy Before:=Sheets(4)
where 4 stands for sheet number 4 (even if sheet 3 is hidden). Sheet number 5 is then "Special".

It is a complicated to use the sheets' numbers instead of the names I have given them. Any move of a sheet makes the macro not work as intended and I also have the intention to let a macro copy and rename sheets so keeping track of the numbers will be tough.

Do you know a way how solve this? Thanks in advance!





Edited by - benes on 12/10/2006 9:09:09 AM

Date Type - Type Mismatch
hello,

Dim DOBQ as Date, cDOBQ as String

Why is it that

cDOBQ = Text4.Text
DOBQ = CDate(cDOBQ)

Returns a mismatch error?

Thanks

Concating Data Of More Than One Excel Sheet To One Sheet In The Same Work Book
Dear

I want to concate data of sheets in to another sheet in the same work book through VB.Please help me

VB In Excel - Trying To Display Cells From Sheet To Sheet.
I'm going to go ahead and appologize for asking this, but I have no idea where to even start to search.

What I am trying to do is run and excel macro that will look for an specific enrty in column A. The entry it is searching for can happen multiple times. I want it to then display the information in columns B-F, respective to the the criteria in column A. (If the search is met in column A, that row I want displayed on a new sheet within the workbook)

I'm pretty sure that I can get info to display from one sheet to another. But my problem is how to run the loop so that it will search column A, and dipslay all respective information in columns B-F, if their column A meets the criteria. And stop when it gets to the bottom of the data, obviously.

Any help is so much appreciated. Also if you could just refer me to another section/topic, that will work too. Thanks in advance.

-g2

One Excel Sheet Monitoring Another Sheet's Events
I've written some macros that open an excel workbook and when an account number is typed into a user defined cell or cells the name associated with that account number is plugged into another user defined cell from the workbook the macros opened. I think my co-workers would find these macros very useful, the problem is none of them are very computer literate, and I don't want to have to go around and set these macros up on their excel workbooks. I would like to have these macros stored in a single sheet, but be triggered by the events of the sheets created by my co-workers without them having to insert any code into the sheets they create... just insert the sheet with the macros. Does anybody know if this is possible?? I appreciate any of the help I can get!!! I'm getting frustrated!!!

Run Macro When Sheet Is Selected
Is there anyway I can run a macro when a user selects a certain sheet.

I know it's possible to do things on file open and close. I've tried using application.volatile, but that only works on recalcuatlions on sheets in which that function is used, selecting a different sheet is not a calculations.

I know code I want to run when the sheet is selected, i'm just a little unsure on how to make it run when sheet1 is selected.

Macro To Save Only One Sheet
Hi everyone its me again sorry for all the newbie questions

i am trying to make a macro that will save a hidden sheet i have. if i manually open the sheet and go save as it does it fine but if i use a macro all it does is save my workbook which is just a menu.

ActiveWorkbook.SaveAs Filename:= _
"C:Documents and SettingsAdministratorDesktopTeam1Peroid1.prn", FileFormat _
:=xlTextPrinter, CreateBackup:=False

what i would like instead of this is something like

Sheet("name").saveas filename .... but this dosint work or compile

thanks for any help any of you can provide.

Type Mismatch...Data Type Vs. Host Data Type?
I keep receiving the "Type mismatch" error, and I think it stems from several fields containing dates which I am trying to update into a MS Access database. What I am trying to determine is what would be the proper settings for the "Data Type" and "Host Data Type", under the Parameters tab in my Command properties? The format I am hoping to achieve is mm/dd/yyyy. (This is already correctly set in my Regional Settings.) I hope this makes sense...I have been searching the forums and haven't found any descriptions yet of the various options for these two settings.

Type Mismatch??
Code:
Dim DI As DirectInput8 'The DirectInput object! DOUBLE-DUH!

'----Devices----------
Dim Mouse As DirectInputDevice 'Input Device object we'll use for the mouse
Dim Keyboard As DirectInputDevice
'---------------------
Dim MState As DIMOUSESTATE 'Mouse state type
Dim KState As DIKEYBOARDSTATE
Const MOUSE_SPEED = 2 'Speed of mouse cursor movement

'----------Cordinates
Dim MouseX As Integer 'X Coordinate of the mouse cursor
Dim MouseY As Integer 'Y Coordinate of the mouse cursor
'----------Button
Dim LMouseButton As Boolean 'Is the left mouse button being pressed?
Dim RMouseButton As Boolean 'Is the right mouse button being pressed?
'----------------------



Public Sub InitDI()
'On Local Error GoTo ErrOut

'-------Setup--------------------------------
Set DI = DX.DirectInputCreate()
Set Mouse = DI.CreateDevice("GUID_SysMouse")<<Type Mismatch
'--------------------------------------------
Mouse.SetCommonDataFormat DIFORMAT_MOUSE

Mouse.SetCooperativeLevel DXForm.hWnd, DISCL_FOREGROUND Or DISCL_EXCLUSIVE

Mouse.Acquire 'Acquire Object
'----Cords-----------------------------------
MouseX = 0
MouseY = 0
LMouseButton = False
RMouseButton = False
'---------------------------------------------
Exit Sub

ErrOut:
'Display an error message and exit if initialization failed
MsgBox "Unable to acquire mouse input exclusively."
End


End Sub

Type Mismatch
alright. im gettin a type mismatch error when i try to load my map to my paintball game.
this is the line that i get errors from.


Code:
retval = LoadMap(Primary, Map, "map1")
retval is dimmed as long. i have also tried it like this.

Code:
loadmap primary, map, map1 'with and without quotes around
'map1
i think it could be related to the function itself. here is the code for that.


Code:
Public Function LoadMap(PrimarySurface As DirectDrawSurface7, BackBufferSurface As DirectDrawSurface7, MapToLoad As Byte)
Open App.Path & "/maps/" & MapToLoad & ".pbg" For Input As MapToLoad
Set BackBufferSurface = DD.CreateSurfaceFromFile(MapToLoad, ddsd2)
End Function
The error is realy bothering me. ive been trying multiple things but they arent working. Also..
did the IRC Channel change from NewNet - #visualbasicforum?
Cause when i get on it makes me an op and nobody else is there.

Thanks

Type Mismatch???
Code:
Dim SrcRect As RECT 'The screen size
Dim DestRect As RECT 'The bitmap size
DX.GetWindowRect frmMain.PicBox.hwnd, ByVal SrcRect
With ByVal in there i get Type Mismatch from SrcRect, without ByVal in there i get ByRef Arguement Type Mismatch from SrcRect.......i really dont understand why but i mite as well see if anyone else does..

-Andrew

Type Mismatch
For w = List1.ListCount - 1 To 0 Step -1
lineItem = List1.List(w)
FormWrestlers.List1.RemoveItem lineItem
List3.RemoveItem lineItem
List1.RemoveItem lineItem
Next w

this code is generating the error "type mismatch" im not too sure why it is doing this as when i press debug and put my mouse over the line giveing the error it shows the line i want to remove?

Type Mismatch
Hi folks, this one's got me stumped. I've created a little timer program for use in-game for a game called EVE-Online.

I charge ingame currency for this little baby, so I won't be surprised if this guy is just trying to get his money back. It's a crooked game, EVE is.

Anyway, there are quite a few players currently using my program and he's the only one complaining about a type mismatch error when he fires up the timer.

I can't duplicate the error for the life of me. I have the fields validate, so if there is a non-numeric value in the field, it clears the whole field when the validation fires. I've completely uninstalled the prgram and removed all settings in the registry, then reinstalled and tried again, but no error on my side, and he continues to claim the same error on his.

Can anyone help me figure out a way to either track this error down, or prove this guy is trying to pull a fast one?

here is the event within which the error is ocurring. He says he does not hear the PlaySound event of the button clicking. So, I assume it's in that first segment of code. I placed the underline breaks to segregate that segment.


Code:
Private Sub btnActivateTimer_Click(Index As Integer)

'Check Mining rate, Size of Roid, and cycle duration
If ( _
_
Me.txtMiningRate(Index).Text = vbNullString _
Or Me.txtSizeOfRoid(Index).Text = vbNullString _
Or Me.txtCycleDurationInSeconds(Index).Text = vbNullString _
_
Or Me.txtMiningRate(Index).Text = "0" _
Or Me.txtSizeOfRoid(Index).Text = "0" _
Or Me.txtCycleDurationInSeconds(Index).Text = "0") _
_
And Me.lblSizeOfRoid(Index).Caption = vbNullString Then
'Do nothing
Exit Sub
End If

'Play CLICK_TICK sound
PlaySound App.Path & " ick1.wav", ByVal 0&, SND_FILENAME Or SND_ASYNC

'Move to next roid if not currently mining
If Me.lblSizeOfRoid(Index).Caption = vbNullString Then

'Move value from Next Roid to Size of Roid label
Me.lblSizeOfRoid(Index).Caption = Me.txtSizeOfRoid(Index).Text
Me.lblOreName(Index).ToolTipText = " Original Size: " & Me.lblSizeOfRoid(Index).Caption & Space(1)
Me.txtSizeOfRoid(Index).Text = ""
mtAsteroid(Index).dblVolume = CDbl(Me.cboRoidType(Index).Tag)
mtAsteroid(Index).strAsteroidName = Me.cboRoidType(Index).Text
Me.lblOreName(Index).Caption = mtAsteroid(Index).strAsteroidName

'Save current Mining Rate in Plus/Minus buttons
Me.lblPlusOne(Index).Tag = Me.txtMiningRate(Index).Text
Me.lblMinusOne(Index).Tag = Me.txtMiningRate(Index).Text

'Reset Progress Bar
Me.lblProgress(Index).Width = 1095

End If

'Load laser values
mtAsteroid(Index).dblMiningRate = CDbl(Me.txtMiningRate(Index).Text)
mtAsteroid(Index).dblCycleDuration = CDbl(Me.txtCycleDurationInSeconds(Index).Text)
mtAsteroid(Index).dblCycleSecondsLeft = mtAsteroid(Index).dblCycleDuration

'Get Asteroid mining rates
Call GetMiningRates(Index)

'Show countdown timer
Me.lblCycleCountdown(Index).Caption = mtAsteroid(Index).dblCycleDuration
Me.lblCycleCountdown(Index).Font.Size = 10
Me.lblCycleCountdown(Index).Top = CYCLE_LABEL_TOP

'Show progress bar and Start timer
Me.lblCycleCountdown(Index).ForeColor = &HC0C0C0
Me.lblProgress(Index).Visible = True
Me.tmrMiningLaser(Index).Interval = DELAY_TIMER
Me.tmrMiningLaser(Index).Tag = 1
Me.tmrMiningLaser(Index).Enabled = True
mtAsteroid(Index).dblTick = Time
mtAsteroid(Index).dblTimeElapsed = 0

'Update Caption
If Me.btnActivateTimer(Index).Caption <> "!" Then

'STARTED MINING
Me.btnActivateTimer(Index).Caption = "!"
Me.txtMiningRate(Index).ForeColor = &H80000015
Me.txtMiningRate(Index).Locked = True
Me.txtCycleDurationInSeconds(Index).ForeColor = &H80000015
Me.txtCycleDurationInSeconds(Index).Locked = True
Me.btnActivateTimer(Index).ToolTipText = " Stop Timer "

Else

'STOPPED MINING
Me.lblCycleCountdown(Index).ForeColor = &HC0C0C0
Me.lblTimeLeft(Index).ForeColor = &HFF8080
Me.btnActivateTimer(Index).Caption = Index + 1
Me.tmrMiningLaser(Index).Enabled = False
Me.tmrMiningLaser(Index).Tag = 0
Me.txtMiningRate(Index).Locked = False
Me.txtMiningRate(Index).ForeColor = vbInactiveBorder
Me.txtCycleDurationInSeconds(Index).Locked = False
Me.txtCycleDurationInSeconds(Index).ForeColor = vbInactiveBorder
Me.btnActivateTimer(Index).ToolTipText = " Start laser first "
Me.lblSizeOfRoid(Index).ToolTipText = " Double click to clear "

End If

End Sub

Type Mismatch
Let me apologize in advace for being non-specific about this, but I can't narrow it down much further.

My code runs fine with Round(Value1,2) + Round(Value2,2)..., but gives me a mismatch when I use FormatNumber(Value1,2) + FormatNumber(Value2,2)... Value1 Value2, etc. are as Single. Is there something that I need to look out for in FormatNumber?

Type Mismatch Help
I just can't seem to get my variables right. I understand why I have the type mismatch, but I don't understand how to correct it. I cannot get to my other "problems until I get this corrected. Type mismatch error in
strMonth = Int(lstMonthName)
intDay = lstMonthDay.

I have 3 ListBox objects and 3 CommandButton objects.

lstMonth (Jan-Dec)

lstDay (1-31)

lstOutput (Opens a file and displays events that occured on the date selected)

cmdGet (Main code button - shows month/day selected, gets the file and opens it, has a Do While loop to read data from the retrieved file one at a time until it gets an EOF condition)

cmdClear (Clears lstOutput of any data)

cmdExit (Exits program)

Can someone please offer some suggestions? I am stumped! I have read from the Tutor's Corner and from doing a search of type mismatch errors but I don't see anything that I can apply. Thanks.

Here is my code:

VB:
Option Explicit

Private Sub cmdFetch_Click()

Dim intCounter As Integer
Dim intDay As Integer
Dim intYear As Integer
Dim strEvent As String
Dim strMonth As String
Dim strRecord As String

strMonth = Int(lstMonthName)
intDay = lstMonthDay

strEvent = "c:is1733kkr7hw11 rivia.dat"
strRecord = strMonth & intDay & intYear & strEvent
intCounter = 0

Open strEvent For Input As #1

lstOutput.Clear

Do While Not EOF(1)
Input #1, strRecord
If strMonth = 7 And intDay = 24 Then
lstOutput.AddItem ("On this day in history:" & intYear & ":" & strEvent)
intCounter = intCounter + 1
End If
Loop
Close #1

End Sub

Type Mismatch?
I cannot find a single thing wrong with this code or line and i still get the same error, here is the code:


Code:
Dim PropBag As New PropertyBag
Dim VarTemp As Variant
Dim BeginPos As Long
Dim ByteArr() As Byte
e = vbCrLf

Infile = FreeFile

Open List2.List(List2.ListIndex) For Binary As #Infile
Get #1, LOF(1) - 3, BeginPos 'Get the start position of data

Seek #1, BeginPos 'Seek to start
Get #1, , VarTemp 'Get the property bag

ByteArr = VarTemp
PropBag.Contents = ByteArr 'Load the property bag

PropBag.WriteProperty "LOF", LOF(1)
PropBag.WriteProperty "BeginPos", BeginPos
Close #Infile

With PropBag
RichTextBox2.Text = .ReadProperty("Name") & e & .ReadProperty("Formula")
Set imgPic.Picture = .ReadProperty("Picture")
End With
I get a Type Mismatch on line "ByteArr = VarTemp"

Type Mismatch But Why?
HI the following code returns a type mismatch only on certain lines

Private Sub mNew_Change(Index As Integer)
Dim mO As Integer
Dim mN As Integer
Dim mB As Integer
Dim mD As Integer
mO = CInt(mOpening(Index).Text)
mN = CInt(mNew(Index).Text)
mB = CInt(mBalance(Index).Text)
mD = CInt(mDespatch(Index).Text)
mB = (mN + mO) - mD
End Sub

The two lines beginning mO and mN are fine but mB and mD both return Type mismatch, runtime error 13, any idea's why

Thanks

Getting Type Mismatch
Code:
Private Sub CommandButton7_Click()

'UAD_FLG

Dim sValue1 As String
Dim sValue2 As String
Dim sValue3 As String
Dim sValue4 As String
Dim sValuex As String
Dim sscript As String
Dim sscript2 As String
Dim sscript3 As String
Dim x As String
Dim finalstring As String

Dim temp1 As Integer




Dim lRow As Long
Dim lRowx As Long
Dim lColValue1 As Long
Dim lColValue2 As Long
Dim lColValue3 As Long
Dim lColValue4 As Long
Dim lColValue5 As Long
Dim stemp1 As String
Dim sum As Integer

Dim a As String




'====================================
'FLAG 1 CALL
'====================================
lRow = 3
lColValue1 = 5
lColValue2 = 11
lColValue3 = 12
lColValue4 = 13

Call WriteToTextFile10("")
Call WriteToTextFile10("---------UDA_FLG started")


While Not Cells(lRow, lColValue1) = ""
sValue1 = Cells(lRow, lColValue1)
sValue2 = Cells(lRow, lColValue2)
sValue3 = Cells(lRow, lColValue3)
sValue4 = Cells(lRow, lColValue4)

sscript = "INSERT INTO SYS_PARAMS(SECTION_NM,VARIABLE_NM," _
& " VARIABLE_VALUE, CREATE_ID, CREATE_DT, UPDATE_ID, UPDATE_DT) Values('UAD_FLG','"

sscript2 = ",'P22919',SYSDATE,'', NULL);"
temp1 = 0
sum = 0

For lRowx = 3 To 78
For lColValue5 = 11 To 13
sValuex = Cells(lRowx, lColValue5)
If lColValue5 <> 13 Then
If sValuex <> "" Then
sscript3 = sscript3 & sValuex & ","
sValuex = Cells(lRowx, lColValue5)
Else
value = CInt(sValuex)
sum = sum + value
If sum == 100 Then
sscript3 = sscript3 & "'"
Else
sscript3 = sscript3 & temp1 & ","
End If
End If
I am getting typemismatch when i am trying to use CInt function here.Can you give me some idea to help me out.

Thanks
Namish

Type Mismatch
Ok Im at a loss, can someone please explain why the following gives a type mismatch

Code:
Private Sub cmdMakeRoom_Click()
Dim ctlRoom As Control
Set ctlRoom = CreateControl(Form_frmGrid2, acRectangle)
...

Type Mismatch '13
I get this type mismatch error '13 when i try to read the value of a cell in excel. Here is the code i am getting an error on:

Code:
Dim DateCells As Integer
DateCells = myworksheet.UsedRange.Columns("A").Rows.Value
What i am trying to do is make it read the last used cell in column A and if its not the current date then have it write the current date in the next empty cell. here is the whole code:


Code:
Option Explicit
Dim myexcel As Object
Dim myworkbook As Object
Dim myworksheet As Object
Dim tmpSheet As Object
Dim Row As Integer
Dim col As Integer
Dim i As Integer
Dim hardwarecount As Integer
Dim DateCells As Integer
Dim DateRow As Integer


Private Sub cmdHardware_Click()
myexcel.DisplayAlerts = False ' will prompt user to save file when it quit among other alerts.

hardwarecount = myworksheet.Range("D" & DateRow)

myworksheet.Cells(DateRow, "D") = hardwarecount + 1

End Sub


Private Sub Form_Load()
Set myexcel = Excel.Application
Set myworkbook = myexcel.Workbooks.Open(App.Path & "Calls.xls")
Set myworksheet = myexcel.ActiveWorkbook.Worksheets("Sheet1")

DateCells = myworksheet.UsedRange.Columns("A").Rows.Value
DateRow = myworksheet.UsedRange.Rows.Count

If DateCells <> Date Then
DateRow = myworksheet.UsedRange.Rows.Count + 1
myworksheet.Cells(DateRow, "A") = Date
End If
End Sub

Private Sub Form_Unload(Cancel As Integer)

myworkbook.SaveAs FileName:=App.Path & "Calls.xls", FileFormat:=xlWorkbookNormal
myexcel.Quit
Set tmpSheet = Nothing
Set myworksheet = Nothing
Set myworkbook = Nothing
Set myexcel = Nothing
End Sub
Please Help!!

-Billy

Type Mismatch
Friends,
I have a simple question, in my system is necessary a verification of a date called DataDemissao, and this variable will must be empty, but I don't know how write this sintax, I wrote:
if collectionA.datademissao = "" then
...
end if
but the VB show me a message: Type mismatch

How can I wrote correctly this?
Thank you
Folley

Type Mismatch
Code:
iWorld = InputBox("Select a world", "World Number")
sSource = Inet1.OpenURL("http://www.runescape.com/aff/runescape/serverlist.cgi?plugin=0&lores.x=79&lores.y=42")
sKey = Between(sSource, "client.cgi?world=24&plugin=0&lores=79&", " oncontextmenu=")
sKey = Replace(sKey, Right(sKey, 1), "")
sFrame = "<html><frameset cols=0,* rows=0,100% frameborder=1 border=0>" & vbNewLine _
& "<frame src='http://www.runescape.com/aff/runescape/logo.html'>" & vbNewLine _
& "<frame src='http://uk3.runescape.com:80/aff/runescape/mod/advert/banner.cgi?size=468&rs=1'>" & vbNewLine _
& "<frame src='http://uk3.runescape.com:80/aff/runescape/mod/advert/banner.cgi?size=120&rs=1'>" & vbNewLine _
& "<frame src='" & "http://www.runescape.com/aff/runescape/client.cgi?world=" & iWorld & "&plugin=0&lores=79&" & sKey & "'>" & vbNewLine _
& "</frameset></html>"
Open "C:
sworld.tmp" For Output As #1
Print #1, sFrame
Close #1
runeweb.Navigate2 ("C:
sworld.tmp")
iWorld = InputBox("Select a world", "World Number")

^^ When pressing cancel I get a "Type Mismatch" Error ^^

Any help is appreciated

Type Mismatch
I have been working on trying to get my program to install and run on another computer for about 2 weeks now, with no success. I keep getting a Type Mismatch error on the target computer. The program will load after getting the error, and everything looks like it is there except for all of the labels. Does anyone know if there is a ocx file that makes the labels work on a program after being installed? I went through the package and deploy to see what files are needed, and I added all of them in my install program, but I still get the Type Mismatch error. I have gone throught my code a dozen times and I am sure I have got rid of any bugs. Also I can install the program back to the computer that was used to create the program and everything works great. Any thoughts, anyone?

This Is A Type Mismatch?
I'm confused. This is the same sort of code that I use elsewhere in the program and it works great there. But here I get a 'Type Mismatch' Error (13).
MyCharacter is a collection. objMember.Key is a string. An Item is a single member of MyCharacter. lvwLst is set to visible False, and lvwReport. Anybody have any ideas why I should be getting this error?


Code:
Private Sub Form_Load()
Dim inHold As Integer, inCnt As Integer, inDflt As Integer, inCnt2 As Integer
Dim stDam1 As String, stDam2 As String
Dim objMember As Item
Dim itmX As ListItem
Dim boDo As Boolean

'Do Some other stuff here
For inCnt = 1 To 7
lvwLst.ListItems.Clear
lvwLst.ColumnHeaders.Clear
lvwLst.ColumnHeaders.Add 1, "Item", "Item"
Select Case inCnt
Case 1
lvwLst.ColumnHeaders.Add 2, "Value", "Value"
Case Else
lvwLst.ColumnHeaders.Add 2, "Value", "Value"
lvwLst.ColumnHeaders.Add 3, "Cost", "Cost"
End Select
For Each objMember In MyCharacter
Select Case inCnt
Case 1
'Other Stats
If objMember.Section = "STATS" Then
If objMember.Key = "Will" Or _
objMember.Key = "Hearing" Or _
objMember.Key = "Fright Check" Or _
objMember.Key = "Vision" Or _
objMember.Key = "Taste/Smell" Or _
objMember.Display = True Then
Set itmX = lvwLst.ListItems.Add(, , objMember.Key) 'This is where the type Mismatch occurs
itmX.SubItems(1) = CStr(objMember.Value)
End If
End If
Case 2
If objMember.Section = "ADS" Then boDo = True
Case 3
If objMember.Section = "DISADS" Then boDo = True
Case 4
If objMember.Section = "QUIRKS" Then boDo = True
Case 5
If objMember.Section = "POWERS" Then boDo = True
Case 6
If objMember.Section = "SKILLS" Then boDo = True
Case 7
If objMember.Section = "SPELLS" Then boDo = True
End Select
If boDo = True Then
Set itmX = lvwLst.ListItems.Add(, , objMember.Key)
itmX.SubItems(1) = CStr(objMember.Value)
itmX.SubItems(2) = CStr(objMember.Cost)
boDo = False
End If
Next
'If sort command is required do here
For inCnt2 = 1 To lvwLst.ListItems.Count

Next
Next
End Sub

Type Mismatch
Im not sure why I am getting this but I am getting a type mismatch after I install my program to another computer. It works fine on my computer but not when I install it to another computer. I compiled the program without any errors. I even installed it my my computer and it works fine. My question is, how do you track down a type mismatch error when the program does not give an error until it is compiled and installed to another computer?

Type Mismatch
Can someone tell me why I get a "Type Mismatch" with this code?

Code:
If GrowthList.Visible = True Then
GrowthList.ListItems.Add (HBP1Grid(0).TextMatrix(0, 0) & " " & "/" & " " & HBP1Grid(1).TextMatrix(0, 0))

Type Mismatch
Could someone please tell me why I am getting a Type Mismatch on this line please?
lCurELine = CLng(.TextMatrix(lRow, 0)) + 1
Thanks


Code:
Public Sub AddToList()

Dim lRow As Long
Dim lCurELine As Long
Dim intResponse


'On Error GoTo dbErrHandler
With Form1.ListGrid
.Redraw = False
Form1.ListGrid.AddItem (Form1.ELine.Text & vbTab & Form1.ECat.Text & vbTab & _
Form1.EItem.Text & vbTab & Form1.EServ.Text & vbTab & Form1.EPoint.Text & _
vbTab & Form1.ECal.Text & vbTab & Form1.ECarb.Text & vbTab & Form1.EPro.Text & _
vbTab & Form1.EFat.Text), Form1.ELine ' insert new line
For lRow = Form1.ELine + 1 To .Rows - 1
lCurELine = CLng(.TextMatrix(lRow, 0)) + 1
.TextMatrix(lRow, 0) = CStr(lCurELine) 'Updates index number below new line
Next lRow
.Redraw = True
End With
Form1.ListGrid.TopRow = Form1.ELine 'Makes new entry visible

Form1.ELine = "" ' Clears input boxes
Form1.ECat = ""
Form1.EItem = ""
Form1.EServ = ""
Form1.EPoint = ""
Form1.ECal = ""
Form1.ECarb = ""
Form1.EPro = ""
Form1.EFat = ""



Form1.ELine.SetFocus
Exit Sub

dbErrHandler:
intResponse = MsgBox("There is no information to enter!", 0)

End Sub

Type Mismatch??
Hi there.

Looking at code examples always seems to raise questions. I see a long evaluated as "true" and it makes me wonder.

In one part of the code we have:


Code:
Dim lDone As Long

later on we see


Code:
Loop While lDone = 0

so far so good, but then...


Code:
Private Sub Form_Unload(Cancel As Integer)
lDone = True

Is that a mismatch? Theres no error. Is a boolean a 1 or a 0? I'm a little confused...

Can Anyone See Why I Have A Type Mismatch Here?
Code:
Public Sub speedAverage()
Dim sum As Double
Dim number As Double
Dim mean As Double

For i = 0 To UBound(speedArray)
number = CDbl(speedArray(i))
sum = sum + number
Next
mean = sum / i
MsgBox "The mean is: " & mean
End Sub

The problem seems to be here:


Code:
number = CDbl(speedArray(i))

speedArray is an array of Strings

Type Mismatch
I get the following error message when i try to run a program i am working on:

Run-Time Error 13
Type Mismatch

here is the code im using, that seems to be generating the error:

Private Sub Label6_Click()
Form1.Show
For i = 1 To textCounter
Form1.Text1.Text = Form1.Text1.Text & vbCrLf & dates(textCounter) Form1.Text1.SelStart = Len(Form1.Text1.Text)
Next i

End Sub

the program reads an array if data from a text file, and prints it into a textbox. textCounter is the variable that counted the lines of text in the file. could comeone please tell me what's wrong? thanks!

Type Mismatch
First Im not sure if this belongs in the game programming forum or not, as the problem is the code being written wrongly. If it is the wrong forum please move it.

Im trying to set up the AI players in this turn based game, but it gives a type mismatch error, I use similar code for the human players and that works fine, thats whats bugs me.

Here is the code:


Code:
If FindStringInFile("Species", Species) = -1 Then
MsgBox ("Invalid Species!")
'Exit Sub
Else

If Name = " " Then
MsgBox ("You cant be nameless!") '
Exit Sub
End If
Dim Occup As Boolean
Dim Check As Integer
Occup = False
Check = 0
Do Until Check = 10
If PC(Check).Species = FindStringInFile("Species", Species) Then
Occup = True
End If
Check = Check + 1
Loop

If Occup = True Then
MsgBox ("That species is allready taken by another player!")
Else
MsgBox "Test"
ActivePlayer = ActivePlayer + 1
Label1.Caption = "Player " + Str(ActivePlayer) + " Make you'r choices!"
PC(ActivePlayer).LeaderName = Name
PC(ActivePlayer).Credits = 15000
PC(ActivePlayer).Scisknown(ReadDataFile("Species", FindStringInFile("Species", Species), 9, 1)) = 1
PC(ActivePlayer).Scisknown(ReadDataFile("Species", FindStringInFile("Species", Species), 10, 1)) = 1
PC(ActivePlayer).Scisknown(ReadDataFile("Species", FindStringInFile("Species", Species), 11, 1)) = 1
PC(ActivePlayer).Scisknown(ReadDataFile("Species", FindStringInFile("Species", Species), 12, 1)) = 1
PC(ActivePlayer).Species = FindStringInFile("Species", Species)
Plnts(ReadDataFile("Species", FindStringInFile("Species", Species), 14, 1)).Owner = ActivePlayer
If ActivePlayer = HumanPlayers Then
Dim InitAI As Byte
Dim AIS As Integer
AIS = 0
'Set up computer players
Do Until AIPlayers = 0
AIPlayers = AIPlayers - 1
ActivePlayer = ActivePlayer + 1
Occup = True
Do Until Occup = False
AIS = AIS + 1
Occup = False
Check = 0
Do Until Check = 10
If PC(Check).Species = AIS Then
Occup = True
End If
Check = Check + 1
Loop
If Occup = False Then
Call SetUpCPU(ReadDataFile("Species", AIS - 1, 1, 1), ActivePlayer)
End If
Loop
Loop
Form2.Hide
Form3.Show
End If
End If
End If
End Sub

Public Sub SetUpCPU(Species As String, ActivePlayer As Byte)
'Species = Int(Species)
Dim Temp As Integer
Temp = FindStringInFile("Species", Species)
PC(ActivePlayer).LeaderName = Name
PC(ActivePlayer).Credits = 15000

PC(ActivePlayer).Scisknown(ReadDataFile("Species", Temp, 9, 1)) = 1
PC(ActivePlayer).Scisknown(ReadDataFile("Species", Temp, 10, 1)) = 1
PC(ActivePlayer).Scisknown(ReadDataFile("Species", Temp, 11, 1)) = 1
PC(ActivePlayer).Scisknown(ReadDataFile("Species", Temp, 12, 1)) = 1
PC(ActivePlayer).Species = FindStringInFile("Species", Species)
Plnts(ReadDataFile("Species", FindStringInFile("Species", Species), 14, 1)).Owner = ActivePlayer
End Sub

Type Mismatch ?
When ever i do not enter a value in txtNumber text box, i get a type mismatch error ? Can someone point out what it is and how to fix it in my code, thank you.


Option Explicit
Dim mintTotalPieces As Integer
Dim mintInputNumber As Integer
Dim mintWorkerCount As Integer
Dim mcurFinalAnswer As Currency
Dim mcurTotalPay As Currency



Private Sub cmdCalculate_Click()
'Define Varibles

mintInputNumber = Val(txtNumber)


'Perform Calculations
If txtNumber.Text = "" Then
If txtName = "" Then
MsgBox "Please Enter Your Name", vbOKOnly, "Missing Input"
End If
MsgBox "Please Enter Number Of Piece's Completed", vbOKOnly, "Missing Input"
End If

If txtNumber.Text <> "" Then
cmdSummary.Enabled = True
End If


If txtNumber > 0 <= 199 Then
mcurFinalAnswer = 0.5 * Val(txtNumber)
ElseIf txtNumber > 199 < 400 Then
mcurFinalAnswer = 0.55 * Val(txtNumber)
End If
If txtNumber >= 400 < 600 Then
mcurFinalAnswer = 0.6 * Val(txtNumber)
End If
If txtNumber >= 600 Then
mcurFinalAnswer = 0.65 * Val(txtNumber)
End If
lblAnswer.Caption = FormatCurrency(mcurFinalAnswer)

If mintInputNumber > 0 Then
mintWorkerCount = mintWorkerCount + 1
End If



End Sub


Private Sub cmdClear_Click()
'Clear all input fields

txtName = ""
txtNumber = ""
lblAnswer = ""
cmdSummary.Enabled = False
End Sub

Private Sub cmdSummary_Click()
'Define variables

Dim strBoxMessage As String
Dim curAveragePay As Currency

curAveragePay = mcurTotalPay / mintWorkerCount
mcurTotalPay = mcurTotalPay + mcurFinalAnswer
mintTotalPieces = mintTotalPieces + mintInputNumber

strBoxMessage = "Total Pieces: " & mintTotalPieces & vbCrLf _
& "Total Pay: " & FormatCurrency(mcurTotalPay) & vbCrLf & "Average Pay: " & FormatCurrency(curAveragePay)



MsgBox strBoxMessage, vbInformation, "Total Pieces"
End Sub

Copyright © 2005-08 www.BigResource.com, All rights reserved