New to VB....probably a stupid question

bellaLANA
05-15-2003, 10:06 PM
Hey....this is probably a really stupid question but i was wandering if anyone could tell me what the message "Type Mismatch" means ... and why it highlights this line when it gives me the error...

g_dPriceArray(iCounter) = Field(sLine, ",", 2)

please....if someone could help that would be great!

ViSioN
05-15-2003, 10:18 PM
It means you declared the variable wrong.. ie. its an integer and you declared it as a string. i cant tell you precisely which variable you declred wrong without seeing where you declared your variables.. but thats where you went wrong.

edit: Hope this helps :)

bellaLANA
05-15-2003, 10:21 PM
Hey Vision, thanks, here are my declarations....i don't understand what i have done wrong... :(

'Global Declarations
Global Const g_iUpperIndex As Integer = 100

'Declare global arrays
Public g_sTitleArray(g_iUpperIndex) As String
Public g_dPriceArray(g_iUpperIndex) As Double
Public g_sCategoryArray(g_iUpperIndex) As String
Public g_dQuantityArray(g_iUpperIndex) As Double

ViSioN
05-15-2003, 10:30 PM
im sorry.. i dont see anything noticably wrong with that. im also a newbie so im unfamiliar with the use of 'Public' as a declaration and Global Const. When I paste those into vb i get like, half a dozen different errors and couldnt figure it out.. someone else will have to help you.. sorry again

another possibility is sLine and iCounter could be declared wrong. you didnt post where you declared them... other than that, i have no more ideas

bellaLANA
05-15-2003, 10:32 PM
No worries ViSiOn...Thanks for ur help anyways! I'm just soooooooo lost when it comes to programming hehe

starbitz
05-15-2003, 10:44 PM
No worries ViSiOn...Thanks for ur help anyways! I'm just soooooooo lost when it comes to programming hehe
Your g_dPriceArray(iCounter) expects a Double type value and your Field(sLine, ",", 2) is not returning that type. That's why you get type mismatch error. What are you expecting to get from Field(sLine, ",",2) by the way? :)

bellaLANA
05-15-2003, 10:56 PM
to tell u the truth i have got no idea! i copied this from a case study we did....and it worked...but now that i am trying it in my assignment, it doesn't. It is supposed to store the second field into the price array.
Sorry i don;t even know if i am making sense here... :(:(:(:(:(:(

VBJoe
05-16-2003, 12:21 AM
Where is the Field function declared? Is it located in a Module in your project? I couldn't find it in my object browser. :confused:

bellaLANA
05-16-2003, 09:56 PM
the declaration for the Field function is in another module in the project...

starbitz
05-16-2003, 10:05 PM
the declaration for the Field function is in another module in the project...
Have you checked also what type it will return? It is supposed to return Double type inorder for you not get the type mismatch error. If it is declared with diffirent return type, then either you need to change that or the type of your Public g_dPriceArray(g_iUpperIndex) :)

bellaLANA
05-16-2003, 10:24 PM
ahhhhhhhhh this is really shi**ing me! lol

the Public g_dPriceArray(g_iUpperIndex) as Double -- is how it is declared in the Field sub

then in another module it is..

Public g_dPriceArray(iCounter) = Field....bla bla

i am sooooooooooooooooo lost!

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum