Thread

VB INI Functions "Compile Error: Type Mismatch" (Sdk)

VB INI Functions "Compile Error: Type Mismatch" // Sdk

1  |  

gamer

Dec 29, 2001, 1:38pm
I'm creating a RPG Bot (yeah yeah, I know, everyones tried it) but its a
good way to put a lot of things I've learn into practise and I've run into a
problem I just can't solve.

So far I've got it Creating Accounts and Character Bio's which can be
changed at any time and viewed by any other player. My problem is that when
I try to run the bot I get "Type Mismatch" on the WritePrivateProfileString.
The thing that its trying to process is a String called Param which holds
the text that needs to be written into the INI file. I'm assuming that this
means that the my INI.bas containing the functions to reading and writting
do not contain the code to except Variables when Writting, becuase if I just
put "Hello" or somthing in, I dont get the error.

Here are my Reading and Writting Functions:

Declare Function GetPrivateProfileString Lib "Kernel" (ByVal
lpApplicationName As String, lpKeyName As Any, ByVal lpDefault As String,
ByVal lpReturnedString As String, ByVal nSize As Integer, ByVal lpFileName
As String) As Integer
Declare Function WritePrivateProfileString% Lib "Kernel" (ByVal
lpApplicationName$, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal
lpFileName$)

those are in INI.bas in my project.

This is the code:

WriteINI = WritePrivateProfileString%(iOwner, "BioRace", Param, FilePath)

Param at this point is equal to nothing or "-", neither make any difference
and it happens whenever someone talks, whether its a command or not..so I
assuming that the compiler is catching it when it does a routine scan
through thr sub before it executes it.

Can anyone help me please? :)

-Gamer

grimble

Dec 29, 2001, 2:24pm
Is the Param variable explicitly declared as a string (i.e. you Dim'd it as
a string) or is it a Variant that contains a string value? The statement
below is a little vague.

[View Quote] > Param at this point is equal to nothing or "-"

baron

Dec 29, 2001, 2:37pm
Couldn't really understand what's wrong from your post but for some reason I think 13 is returned from passing an integer or long to WritePrivateProfileString as first argument, it expects string. Try cStr(iOwner).

-Baron


[View Quote]

gamer

Dec 29, 2001, 3:04pm
Yes, it is Dim'd as String. :)

Any idea whats wrong? I could always paste the whole sub if it helps...

-Gamer

[View Quote]

gamer

Dec 29, 2001, 3:07pm
I'm not passing and integer or long over...just a sting in a variable...

-Gamer

[View Quote]

grimble

Dec 29, 2001, 3:18pm
Good point, assuming that iOwner is still a long at that time.

Gamer, this should get caught by a full compile + Run (Ctrl-F5) ... much
better to identify and fix the syntax related issues before you run the
program, rather than halfway through. If all your variables and parameters
are explicitly declared, you shouldn't get these problems mid-execution
after a full compile.

Grims

[View Quote]

ananas

Dec 29, 2001, 3:20pm
You could (should) change the declaration and
declare them all as string. The kernel function
takes 4 strings (all byval) :

LPCTSTR = constant and zero terminated character pointers

I have no idea what "Any" is (I'm not familiar with VB)
but it somehow looks not right there. The called function
is not an interpreter function but a compiled C function.
C functions will not check the actual type of the VB
variable but expect to be called with the correct type.

--
"_
|
/\
\ /
__/ /_

ananas

Dec 29, 2001, 3:28pm
one more hint :

The kernel function returns a BOOL, that is an integer.
It is 0 (false) when the function failed.

I don't know if it makes any difference for the VB, but
if you try to find an error it might be helpful to see
if the function itself succeeded.

--
"_
|
/\
\ /
__/ /_

gamer

Dec 29, 2001, 5:19pm
Okay, I've sorted the problem (thanks to Grimble), I was using the variables
as local variables in a seperate Sub. I've made them all global now.

I've come across another problem now however, I get a compile error on my
GetPrivateProfileString lines:

e.g. iCreated = GetPrivateProfileString(Param, "Created", , , , filepath)

I know why...it wont let me do , , , , I have to fill each section. Hwoever
that means I have to specify the legnth of the string to return...and since
the users are creating the content of each key, I dont know what the legnth
is...I can put the max value in...but will return a load of spaces after the
actual text I want? I tried doing an example program to test it out but was
having problems with the kernel...does anyone know whether it does? and if
it does, is there a better way to do it or a way or removing the spaces?

-Gamer

[View Quote]

kah

Dec 30, 2001, 3:29pm
put in the max value, when you get the string with a load of spaces, use
Trim() on it, will trim all leading and trailing spaces :-))

KAH

[View Quote]

lanezeri

Dec 30, 2001, 7:08pm
--

Thanks,
Ricky Lipe

Degtur Solutions at http://www.degtur.com
Stuff-X at http://www.stuff-x.com


[View Quote]
begin 666 INI.bas
M071T<FEB=71E(%9"7TYA;64 at /2 B24Y)( at T*1&5C;&%R92!&=6YC=&EO;B!'
M9710<FEV871E4')O9FEL95-T<FEN9R!,:6( at (FME<FYE;#,R(B!!;&EA<R B
M1V5T4')I=F%T95!R;V9I;&53=')I;F=!(B H0GE686P at ;'!!<'!L:6-A=&EO
M;DYA;64 at 07, at 4W1R:6YG+"!">59A;"!L<$ME>4YA;64 at 07, at 4W1R:6YG+"!"
M>59A;"!L<$1E9F%U;'0 at 07, at 4W1R:6YG+"!">59A;"!L<%)E='5R;F5D4W1R
M:6YG($%S(%-T<FEN9RP at 0GE686P at ;E-I>F4 at 07, at 3&]N9RP at 0GE686P at ;'!&
M:6QE3F%M92!!<R!3=')I;F<I($%S($QO;F<-" at T*1&5C;&%R92!&=6YC=&EO
M;B!7<FET95!R:79A=&50<F]F:6QE4W1R:6YG($QI8B B:V5R;F5L,S(B($%L
M:6%S(")7<FET95!R:79A=&50<F]F:6QE4W1R:6YG02( at *$)Y5F%L(&QP07!P
M;&EC871I;VY.86UE($%S(%-T<FEN9RP at 0GE686P at ;'!+97E.86UE($%S(%-T
M<FEN9RP at 0GE686P at ;'!3=')I;F< at 07, at 06YY+"!">59A;"!L<$9I;&5.86UE
M($%S(%-T<FEN9RD at 07, at 3&]N9PT*#0I';&]B86P at <U)E="!!<R!3=')I;F<-
M"D=L;V)A;"!686QU90T*#0I&=6YC=&EO;B!,;V%D24Y)*%-E8W1I;VXL($ME
M>4YA;64L($9I;&5.86UE($%S(%-T<FEN9RD at 07, at 4W1R:6YG#0H at (" at <U)E
M=" ](%-T<FEN9R at R-34L($-H<B at P*2D-"B at ("!686QU92 ]($QE9G0H<U)E
M="P at 1V5T4')I=F%T95!R;V9I;&53=')I;F<H4V5C=&EO;BP at 0GE686P at 2V5Y
M3F%M92P at (B(L('-2970L($QE;BAS4F5T*2P at 1FEL94YA;64I*0T*16YD($9U
M;F-T:6]N#0H-"D9U;F-T:6]N(%-A=F5)3DDH<U-E8W1I;VX at 07, at 4W1R:6YG
M+"!S2V5Y3F%M92!!<R!3=')I;F<L('-.97=3=')I;F< at 07, at 4W1R:6YG+"!S
M1FEL94YA;64I($%S($EN=&5G97(-"B at ("!686QU92 ](%=R:71E4')I=F%T
M95!R;V9I;&53=')I;F<H<U-E8W1I;VXL('-+97E.86UE+"!S3F5W4W1R:6YG
<+"!S1FEL94YA;64I#0I%;F0 at 1G5N8W1I;VX-" at ``
`
end

gamer

Jan 11, 2002, 5:44am
Cheers :)

[View Quote]

1  |  
Awportals.com is a privately held community resource website dedicated to Active Worlds.
Copyright (c) Mark Randall 2006 - 2024. All Rights Reserved.
Awportals.com   ·   ProLibraries Live   ·   Twitter   ·   LinkedIn