Question:
Visual basics help. how do i get the notepad writting to appear in the my textbox?
anonymous
2008-02-19 20:11:04 UTC
in my windows form table, im doing an addressbook for college course and i did a notepad for the contacts but im having trouble importing them into my address table textbox i put.

can you have a look and see what ive done wrong in my code

Sub savefile()
savescreen()

If My.Computer.FileSystem.FileExists(filena... Then
My.Computer.FileSystem.DeleteFile(filena...
End If
For i As Integer = 0 To Counter
Dim recordcontact As String = record(i).Fname = recordcontact + fieldterminator + (i).Surname

recordcontact = recordcontact + Enviroment.Newline
My.Computer.FileSystem.WriteAllText(file... recordcontact
Next
updatescreen()
End Sub
Four answers:
JA12
2008-02-20 01:23:10 UTC
You are half way there, you just need to open the text file for read, and read the lines into a variable - remember the vbCrLf close the file then load the contents of the variable into your text box.



If you really want to do this properly, consider creating a grid control and loading the grid from the text file. You will need to develop an algorithm for segmenting the sections of the addresses, but that should be a nice exercise for you.



For reference purposes, you need to be searching for VB.NET - the code for manipulating controls and file access is all different to VB6
dass
2016-10-20 03:23:28 UTC
I believe Colanth in this one, i began out attempting to pass by way of your code, yet you do no longer even have any comments and you do no longer following any consistent coding style as an occasion, all techniques would want initially a capital letter, all variables would want initially a small letter with each and each be conscious in the call delineated via camel notation, each physique of those small aspects play a extensive function in the code clarity. additionally whilst offering code examples in no way replace code with "...". in case you have the alternative of identifying on how the records is saved i could use an XML document, that way you need to use a XPath question to pass directly to suggestions which you require, even nevertheless this will require you to characteristic one greater filed alongside with an identity which would be a different integer.
anonymous
2008-02-19 20:21:59 UTC
That's writing a file - making the text in an existing file requires reading the file.



FYI, that's VB.Net, not Visual Basic. There's a difference.
iqbal
2008-02-19 20:24:14 UTC
Hi,

First u open ur Notepad file in Visual Basic. The start reding it and assign its value to ur textBoxes.



'for opening a file

open filename for input as #1



'for reading from the file

input #1, a,b,c,d

where a,b,c,d are variables wherin values from ur text file would be saved.

then u write

text1.text=a

text2.text=b

text3.text=c

text4.text=d

this will show the values of variables in textBoxes.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...