Click here to Skip to main content
15,908,013 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: File associations & File Types Editor Pin
Dave Kreskowiak14-Apr-04 4:26
mveDave Kreskowiak14-Apr-04 4:26 
GeneralRe: File associations & File Types Editor Pin
nvmoss14-Apr-04 5:23
nvmoss14-Apr-04 5:23 
GeneralRe: File associations & File Types Editor Pin
Dave Kreskowiak14-Apr-04 8:40
mveDave Kreskowiak14-Apr-04 8:40 
GeneralRe: File associations & File Types Editor Pin
Heath Stewart8-Apr-04 8:50
protectorHeath Stewart8-Apr-04 8:50 
GeneralPass Server Exception to Client proxy Pin
Anonymous8-Apr-04 2:46
Anonymous8-Apr-04 2:46 
GeneralWrite into a text file Pin
Daminda8-Apr-04 0:33
Daminda8-Apr-04 0:33 
GeneralRe: Write into a text file Pin
Dave Kreskowiak8-Apr-04 2:16
mveDave Kreskowiak8-Apr-04 2:16 
GeneralRe: Write into a text file Pin
Nadroj8-Apr-04 3:03
Nadroj8-Apr-04 3:03 
i dont think u can seek to a specific spot in the file to replace just that line, however, someone else should reaffirm this, or otherwise disprove it.

here, i took a little time just now and wrote a sub which will replace any line # in a file, with the string you desire:

<br />
Private Sub TextLineWriter(ByVal fileName As String, ByVal lineNumberToReplace As Integer, ByVal textToWrite As String)<br />
        Dim inFile As IO.StreamReader = IO.File.OpenText(fileName)<br />
        Dim tempString(-1) As String<br />
        Dim i As Byte<br />
<br />
        'read the file given and save each line into a new array element string<br />
        Do Until inFile.Peek = -1<br />
            ReDim Preserve tempString(tempString.Length)<br />
            tempString(tempString.Length - 1) = inFile.ReadLine<br />
        Loop<br />
        inFile.Close()<br />
<br />
        'determine if supplied 'numberToReplace' is valid with the current file,<br />
        'and correct the problem if so<br />
        If lineNumberToReplace - 1 > tempString.Length - 1 Then<br />
            lineNumberToReplace = tempString.Length<br />
        ElseIf lineNumberToReplace - 1 < 1 Then<br />
            lineNumberToReplace = 1<br />
        End If<br />
<br />
        'write the 'textToWrite' at the line number given<br />
        tempString(lineNumberToReplace - 1) = textToWrite<br />
<br />
        'create same file as given (overwriting it) and rewrite the entire file<br />
        Dim outFile As IO.StreamWriter = IO.File.CreateText(fileName)<br />
        For i = 0 To tempString.Length - 1<br />
            outFile.WriteLine(tempString(i))<br />
        Next<br />
        outFile.Close()<br />
    End Sub<br />


use it like this: TextLineWriter("C:\myFile.txt", 3, "Here is my newly put text.")

no need to use Imports system.io for it, it is already specified in the sub.
just copy and paste this exact, as is sub and test it out. please lemme know if this helps.

------------------------
Jordan.
III
Generalanyone can provide simple code for printing??VB.NET Pin
MJay7-Apr-04 21:26
MJay7-Apr-04 21:26 
Generalmultiple projects in a solution Pin
PaleyX7-Apr-04 13:50
PaleyX7-Apr-04 13:50 
GeneralRe: multiple projects in a solution Pin
Dwayne J. Baldwin7-Apr-04 15:30
Dwayne J. Baldwin7-Apr-04 15:30 
GeneralRe: multiple projects in a solution Pin
PaleyX7-Apr-04 16:20
PaleyX7-Apr-04 16:20 
GeneralRe: multiple projects in a solution Pin
PaleyX7-Apr-04 16:54
PaleyX7-Apr-04 16:54 
GeneralRe: multiple projects in a solution Pin
PaleyX8-Apr-04 0:16
PaleyX8-Apr-04 0:16 
GeneralRe: multiple projects in a solution Pin
Dave Kreskowiak8-Apr-04 2:38
mveDave Kreskowiak8-Apr-04 2:38 
GeneralRe: multiple projects in a solution Pin
PaleyX9-Apr-04 1:48
PaleyX9-Apr-04 1:48 
GeneralRe: multiple projects in a solution Pin
Serge Lobko-Lobanovsky12-Apr-04 0:37
Serge Lobko-Lobanovsky12-Apr-04 0:37 
GeneralRemoving service Pin
Lord_Kaos7-Apr-04 10:00
Lord_Kaos7-Apr-04 10:00 
QuestionHourGlass??? Pin
hounetdev7-Apr-04 5:44
hounetdev7-Apr-04 5:44 
AnswerRe: HourGlass??? Pin
Dave Kreskowiak7-Apr-04 5:52
mveDave Kreskowiak7-Apr-04 5:52 
Generalremove a name from list/combo box Pin
GaryKoh7-Apr-04 4:31
GaryKoh7-Apr-04 4:31 
GeneralRe: remove a name from list/combo box Pin
itmpras7-Apr-04 5:03
itmpras7-Apr-04 5:03 
GeneralRe: remove a name from list/combo box Pin
GaryKoh7-Apr-04 16:26
GaryKoh7-Apr-04 16:26 
GeneralRe: remove a name from list/combo box Pin
itmpras7-Apr-04 16:34
itmpras7-Apr-04 16:34 
GeneralRe: remove a name from list/combo box Pin
GaryKoh7-Apr-04 17:43
GaryKoh7-Apr-04 17:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.