Valhalla Legends Archive

Programming => General Programming => Visual Basic Programming => Topic started by: QwertyMonster on March 12, 2005, 08:18 AM

Title: Reading from a .ini
Post by: QwertyMonster on March 12, 2005, 08:18 AM
I want my bot to read from my .ini.

I want to create accounts but using the list from a .ini.

I tried


Dim strCompare as string

Acc1.text = right(Strcompare, 1)



And this is my config code


Public Function OpenConfig()
Dim strCompare As String

   
Open App.Path & "\Names.ini" For Output As #1

     Print #1, "Names to make"
    ' Print #1, "Warning: Do it like this: Username-Password"
     Print #1, "Server: "
     Print #1, "CDKEY: "
     Print #1, "1st: Username:Password"

     Close #1

End Function


And on Form_Load i want it to open that file (ive made it do that atm) and then Read the "1st: " text, and create it or whatever, then go to "2nd: " and so on. But i dont know i can make it read them all. I can only get it read ONE  :-\

Help please? :-*
Title: Re: Reading from a .ini
Post by: Warrior on March 12, 2005, 08:36 AM
Look into these API's


Public Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long


Public Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long
Title: Re: Reading from a .ini
Post by: Archangel on March 12, 2005, 10:00 AM

Private Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Long, ByVal lpFileName As String) As Long

Public Function GetFromIni(AppName As String, Key As String, File As String) As String
Dim Default As String, Size As Integer, Value As Long
Dim User As String
User = Space$(128)
Size = Len(User)
Default = ""
Value = GetPrivateProfileString(AppName, Key, Default, User, Size, File)
User = Mid(User, 1, InStr(User, Chr(0)) - 1)
GetFromIni = User
End Function


For calling function:

Config.ini:

[Configuration]
Username=Dan
Password=Owns


Username = GetFromIni("Configuration", "Username", "C:\Config.ini")
Password = GetFromIni("Configuration", "Password", "C:\Config.ini")


[Edit: Grammar Mistakes]
Title: Re: Reading from a .ini
Post by: Blaze on March 12, 2005, 10:02 AM
Giving people code doesn't help them really.
Title: Re: Reading from a .ini
Post by: Archangel on March 12, 2005, 10:12 AM
Well, not to hard to make though...
Want me to remove code?
Title: Re: Reading from a .ini
Post by: BaDDBLooD on March 12, 2005, 10:55 AM
Quote from: Archangel on March 12, 2005, 10:12 AM
Well, not to hard to make though...
Want me to remove code?

IMO, it would be better to give them the API call and then maybe a short description oh how it works.
Title: Re: Reading from a .ini
Post by: QwertyMonster on March 12, 2005, 02:00 PM
Quote from: Archangel on March 12, 2005, 10:12 AM
Well, not to hard to make though...
Want me to remove code?

Well i didnt copy / paste your code so i cant cheat. But if you want remove it, but if you dont, please comment it. It does help people.


Ok, so now ive got the basic jiff of it. But how would i make it stay the same every time i load it up again? Cos it just goes bk to "".

I put it to go to "", but thats the only way i can save it  :-\

Heres my code

Public Function OpenConfig()
Dim strCompare As String

   
Open App.Path & "\Names.ini" For Output As #1

     Print #1, "Names to make"
    ' Print #1, "Warning: Do it like this: Username-Password"
     Print #1, "Server: "
     Print #1, "CDKEY: "
     Print #1, "1st: Username:Password"
     Print #1, "2nd:"
     Print #1, "3rd:"
     Print #1, "4th:"
     Print #1, "5th:"
     Print #1, "6th:"
     Print #1, "7th:"
     Print #1, "8th:"
     Print #1, "9th:"
     Print #1, "10th:"
     Close #1


See i put it to "", only way i can make it save tbh.

Can anybody help?
Title: Re: Reading from a .ini
Post by: FrOzeN on March 12, 2005, 08:29 PM
Quote from: QwertyMonster on March 12, 2005, 08:18 AMI want to create accounts but using the list from a .ini.

It'd be easier to read lists from a .txt as opposed to an .ini which is better for storing all the details.
Title: Re: Reading from a .ini
Post by: UserLoser. on March 12, 2005, 09:22 PM
Quote from: FrOzeN on March 12, 2005, 08:29 PM
Quote from: QwertyMonster on March 12, 2005, 08:18 AMI want to create accounts but using the list from a .ini.

It'd be easier to read lists from a .txt as opposed to an .ini which is better for storing all the details.

What makes it easier to read from a file with a certain extension opposed to another?
Title: Re: Reading from a .ini
Post by: Blaze on March 12, 2005, 10:11 PM
Quote from: Warrior on March 12, 2005, 09:24 PM
the i and n keys are closer than the t and x keys :P



I agree with UserLoser on this one.

You should use the ini Structure if your going to save the file as a .ini
Title: Re: Reading from a .ini
Post by: FrOzeN on March 13, 2005, 12:22 AM
Well to me it sounded like he wanted to create a accounts from a list.
And lists are normally stored in .txt's.

So inside a Accounts.txt or something he would have something like:
Quotename1:*****
name2:*****
name3:*****
name4:*****
name5:*****
etc..

And then a Config.ini have:
Quote[Settings]
CdKey=0000000000000
Product=PXES
Server=useast.battle.net
;etc..

Instead of something like:

Config.ini:
Quote[Settings]
CdKey=0000000000000
Product=PXES
Server=useast.battle.net


    1st=name1:*****
    2nd=name2:*****
    3rd=name3:*****
    4th=name4:*****
    5th=name5:*****
    ;etc..
If Config.ini's are faster for lists why are they never used to store lists then??

[EDIT] Fixed Tags.
Title: Re: Reading from a .ini
Post by: Warrior on March 13, 2005, 12:27 AM
Why the hell would anyone care about speed (which is barely noticeable) when reading/writing to a file? INI is a more organized way to store information.
Title: Re: Reading from a .ini
Post by: QwertyMonster on March 13, 2005, 04:18 AM
Ok, so now basically now i am using a .txt. Now would i read it like this:




Account1 = App.path & "\names.txt", "Names", "Acc1: "




Something along those lines?
Title: Re: Reading from a .ini
Post by: R.a.B.B.i.T on March 13, 2005, 08:15 AM
This should be in the VB forums and not the BotDev forums.
Title: Re: Reading from a .ini
Post by: QwertyMonster on March 13, 2005, 08:20 AM
Quote from: rabbit on March 13, 2005, 08:15 AM
This should be in the VB forums and not the BotDev forums.

Yes it should.

But does saying that help my problem? I think some people should go back and read some "News" called "Stay on topic".

Not sounding like a flame, so dont take it like one, but that was a useless Post. :-\
Title: Re: Reading from a .ini
Post by: R.a.B.B.i.T on March 13, 2005, 12:59 PM
If the entire thread is in the wrong place, then it's off topic :)
Title: Re: Reading from a .ini
Post by: Blaze on March 13, 2005, 01:37 PM
Quote from: QwertyMonster on March 13, 2005, 08:20 AM
that was a useless Post. :-\

Haha, Thats a lot coming from the king of useless posts.
Title: Re: Reading from a .ini
Post by: QwertyMonster on March 13, 2005, 01:50 PM
Quote from: Blaze on March 13, 2005, 01:37 PM
Quote from: QwertyMonster on March 13, 2005, 08:20 AM
that was a useless Post. :-\

Haha, Thats a lot coming from the king of useless posts.

Oh, haha :-\
 
Now thats alot coming from the Queen of useless posts  ;)

Can we kind of... Get back on topic. Thanks.
Title: Re: Reading from a .ini
Post by: Blaze on March 13, 2005, 01:54 PM
We have already givin you everything you need, plus an example on how to use it... What more do you want?
Title: Re: Reading from a .ini
Post by: MyndFyre on March 13, 2005, 02:47 PM
Quote from: Blaze on March 13, 2005, 01:54 PM
We have already givin you everything you need, plus an example on how to use it... What more do you want?
Do it for me.

Not sounding like a flame, so don't take it like one, but that was the only logical step to go.
Title: Re: Reading from a .ini
Post by: Blaze on March 13, 2005, 02:49 PM
I wanted him to say that, or post the code that we already posted and said it doesn't work. -.-
Title: Re: Reading from a .ini
Post by: QwertyMonster on March 13, 2005, 03:12 PM
Eh i must be blind ;D

Missed the code bit, nvm. Thanks for all help. And thx to that dxiogm person, for posting code so i can learn from it.
Title: Re: Reading from a .ini
Post by: Warrior on March 13, 2005, 05:01 PM
How can you miss code
Title: Re: Reading from a .ini
Post by: QwertyMonster on March 14, 2005, 08:42 AM
Quote from: Warrior on March 13, 2005, 05:01 PM
How can you miss code

No. I didnt mean i MISSED IT. But i looked through it and didnt think it was what i was looking for or needed. But i re-read it and it seems i can make it work for what i need it for. Thanks.
Title: Re: Reading from a .ini
Post by: Grok on March 14, 2005, 03:29 PM
Does every thread have to go into arguments over too much or too little help?  You guys are almost all noobs to programming, and nearly none of you have room to be criticizing someone else who is just starting out.  Your 2-5 years experience doesn't mean jack, especially if it is not in the real world working with teams of programmers and customers on significant projects.  No school work matters, except maybe a few graduate projects (most of those don't matter).

Please stop flooding the threads with useless chest-thumping about how much code was or was not posted to other noobs.
Title: Re: Reading from a .ini
Post by: QwertyMonster on March 14, 2005, 03:34 PM
Sworry :'(  :-*
Title: Re: Reading from a .ini
Post by: UserLoser. on March 14, 2005, 07:14 PM
Quote from: Grok on March 14, 2005, 03:29 PM
Does every thread have to go into arguments over too much or too little help?  You guys are almost all noobs to programming, and nearly none of you have room to be criticizing someone else who is just starting out.  Your 2-5 years experience doesn't mean jack, especially if it is not in the real world working with teams of programmers and customers on significant projects.  No school work matters, except maybe a few graduate projects (most of those don't matter).

Please stop flooding the threads with useless chest-thumping about how much code was or was not posted to other noobs.

I have something to say about this... but I think the lack of moderation due to some people being involved in MMORPGs too much allowed some people to think they could post what they want and it'd be ok since nobody is around to tell them otherwise.  I know I have my bad posts some places in the past, but those don't happen anymore
Title: Re: Reading from a .ini
Post by: Adron on March 15, 2005, 07:32 AM
Quote from: UserLoser on March 14, 2005, 07:14 PM
I have something to say about this... but I think the lack of moderation due to some people being involved in MMORPGs too much allowed some people to think they could post what they want and it'd be ok since nobody is around to tell them otherwise.  I know I have my bad posts some places in the past, but those don't happen anymore

Well, I have been looking at this thread, feeling the itch to split and remove posts, but neither Yoni nor DarkVirus are involved with any MMORPGs at this time as far as I know....
Title: Re: Reading from a .ini
Post by: QwertyMonster on March 15, 2005, 09:44 AM
I have posted a bit of useless posts, and stuipid Posts. And i myself thought admins DID watch, but nothing came apon it. I shall now stop my stuipid / useless posts.
Title: Re: Reading from a .ini
Post by: Grok on March 15, 2005, 12:09 PM
Quote from: QwertyMonster on March 15, 2005, 09:44 AM
I have posted a bit of useless posts, and stuipid Posts. And i myself thought admins DID watch, but nothing came apon it. I shall now stop my stuipid / useless posts.

Some noise just isn't worth our getting involved.  But when the noise level grows very much, one of us sometimes feels compelled to moderate.  Mostly I think we all prefer that our public community has a bit of maturity, focus, self-control, and civility.  That just isn't always true.
Title: Re: Reading from a .ini
Post by: Adron on March 15, 2005, 12:23 PM
Quote from: Grok on March 15, 2005, 12:09 PM
Some noise just isn't worth our getting involved.  But when the noise level grows very much, one of us sometimes feels compelled to moderate.  Mostly I think we all prefer that our public community has a bit of maturity, focus, self-control, and civility.  That just isn't always true.

It's also worth noting that if it comes to admin moderation, it will typically end up involving banning.
Title: Re: Reading from a .ini
Post by: Blaze on March 15, 2005, 01:25 PM
Quote from: Adron on March 15, 2005, 07:32 AM
Well, I have been looking at this thread, feeling the itch to split and remove posts, but neither Yoni nor DarkVirus are involved with any MMORPGs at this time as far as I know....
Well, Yoni is in the Army more then he is here and DarkVirus's Last Active time was January 11, 2005, 11:15 pm.
Title: Re: Reading from a .ini
Post by: UserLoser. on March 15, 2005, 01:29 PM
Quote from: Adron on March 15, 2005, 07:32 AM
Quote from: UserLoser on March 14, 2005, 07:14 PM
I have something to say about this... but I think the lack of moderation due to some people being involved in MMORPGs too much allowed some people to think they could post what they want and it'd be ok since nobody is around to tell them otherwise.  I know I have my bad posts some places in the past, but those don't happen anymore

Well, I have been looking at this thread, feeling the itch to split and remove posts, but neither Yoni nor DarkVirus are involved with any MMORPGs at this time as far as I know....

I was actually trying to talk about a good chunk of forum in general, not just VB one
Title: Re: Reading from a .ini
Post by: Grok on March 15, 2005, 02:48 PM
Quote from: UserLoser on March 15, 2005, 01:29 PM
Quote from: Adron on March 15, 2005, 07:32 AM
Quote from: UserLoser on March 14, 2005, 07:14 PM
I have something to say about this... but I think the lack of moderation due to some people being involved in MMORPGs too much allowed some people to think they could post what they want and it'd be ok since nobody is around to tell them otherwise.  I know I have my bad posts some places in the past, but those don't happen anymore

Well, I have been looking at this thread, feeling the itch to split and remove posts, but neither Yoni nor DarkVirus are involved with any MMORPGs at this time as far as I know....

I was actually trying to talk about a good chunk of forum in general, not just VB one

I read the same forums today that I read before WoW came along.  What's your point?