BP Forums
Problems with multiple textboxes and coding - Printable Version

+- BP Forums (https://bpforums.info)
+-- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=55)
+--- Forum: Archived Forums (https://bpforums.info/forumdisplay.php?fid=56)
+---- Forum: VB.NET (Visual Basic 2010/2008) (https://bpforums.info/forumdisplay.php?fid=8)
+----- Forum: Programming Help (https://bpforums.info/forumdisplay.php?fid=9)
+----- Thread: Problems with multiple textboxes and coding (/showthread.php?tid=276)

Pages: 1 2


Problems with multiple textboxes and coding - LearningVB2010 - 12-24-2010

Hi Brandonio and other helpers,
I want to make a program were i make a map.ini file (this is just txt for a program calld C&C generals).
The one that is using the program can typ in an textbox for oil bonus: 50
and then a txt file appears or it will get saved in it as a code like this:
InitialCaptureBonus = 8000
i have no idea to do this with multiple textboxes or even one, please help me out.

greets from holland ^^


Re: Problems with multiple textboxes and coding - brandonio21 - 12-24-2010

First of all, Welcome to the forums!
Have you seen this tutorial on how to save a text file? <!-- m --><a class="postlink" href="http://www.youtube.com/watch?v=xf67hCwPLIs">http://www.youtube.com/watch?v=xf67hCwPLIs</a><!-- m -->


Re: Problems with multiple textboxes and coding - LearningVB2010 - 12-24-2010

yes, i have seen all your tutorials.





Btw: you said it was save, but it was more a save as <!-- sTongue --><img src="{SMILIES_PATH}/icon_razz.gif" alt="Tongue" title="Razz" /><!-- sTongue --> and i subd.


Re: Problems with multiple textboxes and coding - brandonio21 - 12-24-2010

Haha, Alright just making sure.
So what you wanna do is take the value from a textbox and put it into a .ini file? :O
If so,
Code:
dim writer as new system.io.streamwriter(my.application.info.directorypath + "/map.ini")
writer.writer(textbox1.text)
writer.close



Re: Problems with multiple textboxes and coding - LearningVB2010 - 12-27-2010

well, exually
i want to put a value of a textbox in a part of a written text..
so if i put in 50 in an textbox, and i save it..
.. it will come into an .ini file in a kind of code.
but i don't know how i: save multiple textboxes, change text in an other text automaticly..
.. and a lot of stuff else, i can show you an example of it, if u want.
(i hope you are still following)


Re: Problems with multiple textboxes and coding - brandonio21 - 12-27-2010

Yes, I am still following.
But, Instead of writing in a certain section of the text file, wouldn't it just be easier to rewrite the whole text file??
If you would like to share your example that would be great!


Re: Problems with multiple textboxes and coding - LearningVB2010 - 12-28-2010

Hi again,
I've tried to upload the program, but it diddn't go well.
So I have created an print screen and uploaded it.
link : http://i.imgur.com/bzbTy.png
Img.:[Image: bzbTy.png]
I hope you understand now.


Re: Problems with multiple textboxes and coding - xolara - 12-28-2010

Ill try and have a look at it ^^


Re: Problems with multiple textboxes and coding - LearningVB2010 - 12-28-2010

oh btw,
the numbers you saw in the map.ini file extualy had to be:
DepositTiming = 12000
DepositAmount = 200
InitialCaptureBonus = 1000

sorry <!-- sTongue --><img src="{SMILIES_PATH}/icon_razz.gif" alt="Tongue" title="Razz" /><!-- sTongue -->


Re: Problems with multiple textboxes and coding - brandonio21 - 12-28-2010

Okay, well lets just assume that the textboxes are called capturebonus, normalbonus, and time.
Code:
if my.computer.filesystem.fileexists(my.application.info.directorypath + "/map.ini") then
     my.computer.filesystem.deletefile(my.application.info.directorypath + "/map.ini")
end if
dim writer as new system.io.streamwriter(my.application.info.directorypath + "/map.ini")
writer.write("Object TechOilDerrick" + vbNewLine + "ReplaceModule ModuleTag_04" + vbNewLine + "Behavior = AutoDepositUpdate ModuleTag_04_Override" + vbNewLine + "DepositTiming = " & time.text + "00" + vbNewLine + "DepositAmount = " + normalbonus.text + vbNewLine + "InitialCaptureBonus = " + capturebonus.text + vbNewLine + "End" + vbNewLine + "End" + vbNewLine + "End"
writer.close()


I think this is what you were looking for! <!-- sBig Grin --><img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt="Big Grin" title="Very Happy" /><!-- sBig Grin -->


Re: Problems with multiple textboxes and coding - LearningVB2010 - 12-29-2010

You are a genius, thanks <!-- sBig Grin --><img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt="Big Grin" title="Very Happy" /><!-- sBig Grin -->


Re: Problems with multiple textboxes and coding - LearningVB2010 - 12-29-2010

I finished the program almost,
but i have still (Tongue) a question:
I made a second tab in it for the rank settings.
and i added another change botton on that.
But if I save oil and then the rank. it will delete the map.ini file with the oil settings.
I want that it write's in the map.ini also the rank settings.

So if I press ONLY the Change button of the oil, only the oil settings will come in the map.ini
but if I press both the Change buttons, then the settings will be writed in the same map.ini


Re: Problems with multiple textboxes and coding - brandonio21 - 12-29-2010

So, I'm guessing you want to fix this?... Hold on, lemme do some research and I'll get back to ya. <!-- sBig Grin --><img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt="Big Grin" title="Very Happy" /><!-- sBig Grin -->


Re: Problems with multiple textboxes and coding - brandonio21 - 12-29-2010

Hm. Well what you can do is ... Its kinda complicated but lets see if I can explain it.

Code:
dim reader as new system.io.streamreader(my.application.info.directorypath + "/map.ini")
dim read as string = reader.readtoend
if read.contains("TechOilDerrick") then
  my.computer.filesystem.deletefile(my.application.info.directorypath + "/map.ini")

'At this point you would need to write the RANK settings into the textfile, and somewhere in the writer options you MUST specify appendmode=true
'Then, when appendmode = true, you can then writer.write(read) and it will just add it to the end of the text file

end if

Now, I don't know how well this code would work, because I just came up with it off the top of my head, but it might give you a good idea.


Re: Problems with multiple textboxes and coding - LearningVB2010 - 01-23-2011

Sorry for my REALLY late response, but i was a bit bizzy.
I can't get it working, I don't understand all your codes. So I uploaded it on megaupload and you can download it here: <!-- m --><a class="postlink" href="http://www.megaupload.com/?d=HNMVPYYU">http://www.megaupload.com/?d=HNMVPYYU</a><!-- m -->

No virus ofcourse <!-- sBig Grin --><img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt="Big Grin" title="Very Happy" /><!-- sBig Grin -->.
U can change it and upload it again or just tell me where the problem is.

Thanks for all.


Re: Problems with multiple textboxes and coding - brandonio21 - 01-23-2011

Alright, Well, in the file you uploaded, you didn't upload the source code so I can't edit it. So I will try my best here <!-- sSmile --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt="Smile" title="Smile" /><!-- sSmile -->
OK. Step one. Declare this right under public class form1
Code:
Public writer As New System.IO.StreamWriter(My.Application.Info.DirectoryPath + "/map.ini", True)
Step2 - make 13 settings, and name them capbonus,normalbonus,timebetween,rank1skill,rank2skill,rank3skill,rank4skill,rank5skill,rank1points,rank2points,rank3points,rank4points,rank5points.
-This may seem like alot. That's because it is.

Ok so when each button is pushed, you will change the settings to the corresponding textboxes. For example, when the oil setting is pushed, you will do this :
Code:
my.settings.capbonus = txt_capbonus.text
my.settings.normalbonus = txt_normalbonus.text
my.settings.timebetween = txt_timebetween.text
You will need to do the same thing with the rank tab.
Then, you will need to delete the text file when a button is pushed
Code:
my.computer.filesystem.deletefile(my.application.info.directorypath + "/map.ini")
Then, you can write to the file. Simply replace all the spots where it gets a txtbox.text, with their corresponding settings. And make sure when you click one button, it writes both the rank and the oil settings.


Hope this helped!


Re: Problems with multiple textboxes and coding - LearningVB2010 - 02-04-2011

Hi again,
My computer has been hacked <!-- s:evil: --><img src="{SMILIES_PATH}/icon_evil.gif" alt=":evil:" title="Evil or Very Mad" /><!-- s:evil: -->,
but I had a backup of everything so it's fine now.
I'm working on an update function with a progressbar right now, because your information is a bit hard for me. <!-- s:oops: --><img src="{SMILIES_PATH}/icon_redface.gif" alt=":oops:" title="Embarrassed" /><!-- s:oops: --> still the overwriting is failing.


Re: Problems with multiple textboxes and coding - brandonio21 - 02-04-2011

Bah, I'm sorry to hear your computer got hacked and I'm doubly sorry to hear the coding isnt working out for you <!-- sSad --><img src="{SMILIES_PATH}/icon_e_sad.gif" alt="Sad" title="Sad" /><!-- sSad -->. We can help you with anything else though!


Re: Problems with multiple textboxes and coding - LearningVB2010 - 02-11-2011

I will upload it soon with source code <!-- s:!: --><img src="{SMILIES_PATH}/icon_exclaim.gif" alt=":!:" title="Exclamation" /><!-- s:!: -->


Re: Problems with multiple textboxes and coding - brandonio21 - 02-11-2011

Sweet. Can't wait to see <!-- sBig Grin --><img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt="Big Grin" title="Very Happy" /><!-- sBig Grin -->