Link to home
Start Free TrialLog in
Avatar of ackid32
ackid32

asked on

Open file problem

i want to open an ini file in readwrite mode, when i open it in for output or for input it accept only it type and not allow me to read write
what can i do
Avatar of AzraSound
AzraSound
Flag of United States of America image

Avatar of Ark
Open "TESTFILE" For Binary Access ReadWrite As #1
ackid32:

Last 10 Grade(s) Given:  
A A B B B B B C B D  
Question Grading Record:  
16 / 19  

>>when i open it in for output

When you open a file FOR OUTPUT, it's contents is destroyed, this is:
a) if file doesn't exist, a new file is created
b) if file exists, the file is deleted; then proceed as in a)

OPEN FOR OUTPUT is used when you want to create a file ONLY, not to read an existing file.
Here is one alternate method ackid32. Declare two API functions namely

GetProfileString Or GetPrivateProfileString

And WriteProfileString Or WritePrivateProfileString

U can just pass the Filename, KeyValue and fulfill your needs. Just use GetProfileString to Read data and WriteProfileString to write Date.

<Smile>  Get back to me.
For opening and modifying an  ini file u have to use the api function's GetPrivateProfileString And WritePrivateProfileString respectively for reading and writing info's into an INI file this is available in the File Win32api.txt
under the Program Files \Devstudio\VB\Winapi

When u open this with the Api file viewer u can see the parameters

Thanking U

Cheer's

Prem
Hold on moment. Prem_Kumar_25 has given the same answer as me but he gets the points. how come. Come on ackid32
AshokKumar,

My heart bleeds for you, but if you had read the comments made by wsh2 and me you would have known that ackid32 is not the most decent of contributors to this site.
caraf_g:
How did ackid32 and the word decent get into the same sentence? Ah, now I see.. it was a spelling error.. you meant de-scent.. as in something smells in de-ghetto.. LOL.
It must be nice to be a duck. We're water.
Thanks guys. caraf_Q and wsh2.  Indeed prem needs points desperately it seems. Not my problem really. Right?? Anyway caraf. U have guided me evertime i err. Thanks friend.
Thanks AshokKumar, I know I can sound like a grumpy old man sometimes but I mean well ;-)
Avatar of ackid32

ASKER

Hi, thanks all, i want to open a file to read write simultaneously, i dont want the api calls.
please!
AshokKumar writes "Thanks guys. caraf_Q"
And then writes: "Anyway caraf."

AshokKumar.. it is spelled caraf_g.. do I get to be a guide now too?.. <lol> and a <wink>.

-------------------------------------
caraf_g writes: "I can sound like a grumpy old man"

You ARE a grumpy old man... <laughing>.. bet you can't wait for the EE server to crash again.. <sheesh>.

(Now writing note to Linda.. I left a comment about how caraf_g is a very talented, well respected professional.. but for some reason it now reads grumpy old man?.. Wazzup? Please have an engineer look into this).. <wink>.

-------------------------------------
One last word.. AshokKumar, caraf_g is everything that you believe him to be.. only Better.. <smile> and a <wink>.
U sound pretty good to me caraf. And for you ackid, files can be opened in three modes onlly.

Read (Read-Only)
Write (Write-Only)
Append (Write That be added to an existing file)

I don't know any other method.
Avatar of ackid32

ASKER

Because i make sure that no one can acces that while i open it
ackid32 writes: "i want to open a file to read write simultaneously, i dont want the api calls"

Follow the code closely..

Open https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=10318577 
Pay.Points

Open https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=10316154 
Pay.Points

Open https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=10316153 
Pay.Points

Open https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=10309119 
Pay.Points

Open https://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=10297284 
Pay.Points

and then everything will be ALL...
WRITE

<smile> and a <wink>

wsh2, do you ever watch "One foot in the grave"? I'm Victor Meldrew. <g>

Hi ackid32, thanks for following up. Can I ask you something... Your question history is not very promising; you don't give very good grades and you've occasionally left answered questions hanging in limbo causing them to be autograded. I hope you intend to improve on that record?

The api calls are a good way of achieving what you need. Why not use them?
wsh2. Are u a debugger or what. U seem to find some error in any one's comment. Good for me and for others also. I feel we need a guy like u.
Wsh2,
It should be Points.Pay (object first, method second) or Pay(Points) - Function first, argument - second :-)
Cheers
AshokKumar:
Contrary to what caraf_g wrote.. Do you ever watch "One foot in the grave"? I'm Victor Meldrew.. <LOL>.

Trust me.. All is written with good intent and with tongue in cheek.. I bought my copy of VB in the humor section of the store.. <smile> and a <wink>.


Ark:
ROFLMAO.. well keyed !!!
Guess that's the risk you take when you try to lighten up a thread with a bit of humour - sometimes it can be taken the wrong way. AshokKumar, I've dealt with wsh2 in a few threads so far and my impression is that wsh2 is a decent guy/gal. So I would like fo you people to kiss and make up now!
Avatar of ackid32

ASKER

hi, this is problem i have faced in experts-exchange, that nobody told me the right way to solve my problem and ask for points. Take this question
1. i want to open a file in readwrite mode
2. nobody access that file while i do operations in that file

wsh2 don't see any ones history, also the question & answers. i honestly ranked them and accept those which are ok to "ME" and not to you the nuts. Do you think that you are an expert, idiot, behave like a gentleman, acceptance or reject is up to me and i follow it geniunly. 16/19 is not a bad one and not i gave A & B grades also.
Thanks all except wsh2
caraf. I said in a friendly tone. I have no probs. with wsh2 <Smile> He/She only brightening things up. ackid32. Don't be so rude to wsh2.
ackid32 writes: "hi, this is problem i have faced in experts-exchange, that nobody told me the right way to solve my problem"

In the five questions you left unanswered.. a whole bunch of "nuts" went through a whole bunch of effort and kindly answered you.. with some VERY correct answers I might add! After all that, at the end of these threads, you never even take a moment to explain why the answers are lacking <we EE idiots do like to know.. duh.. lol>.. or even go so far as to extend a Thank You. As you say, I may be a nut and an idiot.. but at least I can say I am not ingracious or rude.. <smile>.

Uh, just for a moment ackid32, did you ever think.. it just might be you?.. <smile> and a <wink>.
caraf. I said in a friendly tone. I have no probs. with wsh2 <Smile> He/She only brightening things up. ackid32. Don't be so rude to wsh2.
AshokKumar:
I found your comments most well intended.. no offense, or thought of it, was ever taken. I very much look forward to working with you in the future.. <smile>. caraf_g is just trying to start trouble.. LOL.. Just kidding !!!
Oh.. and by the way.. in the spirit of EE.. ackid32 maintains that the 5 open questions I alluded to earlier in my comment.. are in need of answering!!!
Check them out.. hear?

Let me know if you can find a better answer to his questions. I mean, assuming that you are NOT a nut / idiot like me.. it should be easy to do.. right ackid32?.. <smile>.
<hands out happy pills>
C'mon people. Peace. Stick flowers in your hair. Dance in the meadows. Visit Haight-Ashbury. Put on your favourite Woodstock album and sing along. Smoke a joint if that's what it takes to make you mellow.... Grrrrooooovey....
Don't forget do don your flowery robe
caraf_g:
<sighing heavily and remembering the 60s>.. Yes caraf_g.. I suppose you are correct.. <now making a PEACE sign with his hand and smiling>.. Ooops.. I am an idiot.. sorry ackid32.. I'm supposed to put up my index finger with the other one too.. <LOL>.. Just kidding !!!! Its a joke.. <sheesh>.

caraf_g.. you ARE a trouble maker.. <wink>.
Avatar of ackid32

ASKER

hi, i have visitors that time, i refused that answers( i state the reason there) and it is now unlocked, so why you blame me, try to answer that or left
Now here's an interesting observation:

ackid32, if I remember correctly you accepted prem_kumar_25's answer, right?

Well, since then EE have moved offices, lost data, kept us all hanging about for a day.... and now, lo and behold, prem_kumar_25's answer is back to its proposed status....

Now, EE has promised that they'll try and restore the data. But I'd be very curious to see what happens if you now go and accept, say, AzraSound's comment as an answer.

Wonder what will happen if EE then comes along and tries to restore the data in this thread. It'd be an interesting experiment. Want to give it a try?
ASKER CERTIFIED SOLUTION
Avatar of vikiing
vikiing

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ackid32

ASKER

i already said above, anybody?
Well, you've received a couple of satisfactory answers. You know what to do.
Avatar of ackid32

ASKER

ok, i accept, thanks all, not to wsh2(nasama ponavan)
nasama ponavan?

Is that the same as lolbôks or is it something altogether more rude? :o)
Well, thanks for the points, and glad to have helped you.