Click here to Skip to main content
16,006,768 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionForm resize : controls alignment and size Pin
nishkarsh_k28-Oct-07 3:34
nishkarsh_k28-Oct-07 3:34 
AnswerRe: Form resize : controls alignment and size Pin
Dave Kreskowiak28-Oct-07 4:30
mveDave Kreskowiak28-Oct-07 4:30 
GeneralRe: Form resize : controls alignment and size Pin
nishkarsh_k28-Oct-07 6:20
nishkarsh_k28-Oct-07 6:20 
GeneralRe: Form resize : controls alignment and size Pin
Dave Kreskowiak28-Oct-07 12:26
mveDave Kreskowiak28-Oct-07 12:26 
QuestionSave as Excel spreadsheet Pin
Dave McCool28-Oct-07 3:22
Dave McCool28-Oct-07 3:22 
AnswerRe: Save as Excel spreadsheet Pin
Paul Conrad28-Oct-07 7:19
professionalPaul Conrad28-Oct-07 7:19 
QuestionGet information from text file Pin
Dave McCool28-Oct-07 3:09
Dave McCool28-Oct-07 3:09 
AnswerRe: Get information from text file Pin
C1AllenS28-Oct-07 5:28
C1AllenS28-Oct-07 5:28 
Hello Dave,

You can try using the following code implementation. In this I have taken a textbox and a button.
On form load, textbox automatically fills with the first line of the file. On button click, it
will check the text box for any changes and then it will do what you require. It will ask for
password and after verifying the password, make the changes back to the file. password is coded
right now. You can use various techniques to read it from a file.

BEGIN CODE

Imports System.IO

Public Class Form1

Dim myline As String


Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

Dim sr As New StreamReader("c:\test.txt", False)
myline = sr.ReadLine
TextBox1.Text = myline
sr.Close()

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim tempstring As String
Dim result As DialogResult

If Not TextBox1.Text.Equals(myline) Then

result = MsgBox("Do you want to save changes", MsgBoxStyle.YesNo, "Save")

If result = Windows.Forms.DialogResult.Yes Then

Dim pass As String = InputBox("Enter the Password", "Admin", "")

If pass = "Password" Then

Dim sr As New StreamReader("c:\test.txt")
Dim sw As New StreamWriter("c:\Temp.txt")
While Not sr.EndOfStream

tempstring = sr.ReadLine()

If Not tempstring.Equals(myline) Then

sw.WriteLine(tempstring)
Else
sw.WriteLine(TextBox1.Text)

End If

End While

sw.Close()
sr.Close()

File.Delete("c:\test.txt")
Rename("c:\temp.txt", "c:\test.txt")

Else
MsgBox("Wrong Password")
Exit Sub

End If

End If

End If

End Sub
End Class

END CODE

I hope this will give you some idea to resolve your issue.

Regards,
Allen

Allen Smith

Software Engineer
ComponentOne LLC
www.componentone.com
Questiondate vb.net2005 & sqlserver 2005 Pin
nilam1128-Oct-07 2:51
nilam1128-Oct-07 2:51 
AnswerRe: date vb.net2005 & sqlserver 2005 Pin
Guffa28-Oct-07 3:15
Guffa28-Oct-07 3:15 
GeneralRe: date vb.net2005 & sqlserver 2005 Pin
nilam1128-Oct-07 3:26
nilam1128-Oct-07 3:26 
GeneralRe: date vb.net2005 & sqlserver 2005 Pin
Dave Kreskowiak28-Oct-07 4:22
mveDave Kreskowiak28-Oct-07 4:22 
GeneralRe: date vb.net2005 & sqlserver 2005 Pin
Salman Sheikh29-Oct-07 22:36
Salman Sheikh29-Oct-07 22:36 
GeneralRe: date vb.net2005 & sqlserver 2005 Pin
Dave Kreskowiak30-Oct-07 2:04
mveDave Kreskowiak30-Oct-07 2:04 
Questionshow currency with 3 decimal places Pin
SamRST27-Oct-07 22:21
SamRST27-Oct-07 22:21 
AnswerRe: show currency with 3 decimal places Pin
Muhammad Shahid Farooq28-Oct-07 8:37
professionalMuhammad Shahid Farooq28-Oct-07 8:37 
GeneralRe: show currency with 3 decimal places Pin
SamRST28-Oct-07 22:39
SamRST28-Oct-07 22:39 
QuestionVB.Net on MacOSX with Mono Pin
ryan11727-Oct-07 18:45
ryan11727-Oct-07 18:45 
AnswerRe: VB.Net on MacOSX with Mono Pin
Dave Kreskowiak28-Oct-07 4:18
mveDave Kreskowiak28-Oct-07 4:18 
AnswerRe: VB.Net on MacOSX with Mono Pin
DaveX8628-Oct-07 5:54
DaveX8628-Oct-07 5:54 
AnswerRe: VB.Net on MacOSX with Mono Pin
ryan11728-Oct-07 22:13
ryan11728-Oct-07 22:13 
GeneralSQL Express Backup Automated Pin
Darcy J Williamson27-Oct-07 9:33
Darcy J Williamson27-Oct-07 9:33 
GeneralRe: SQL Express Backup Automated Pin
Hesham Amin27-Oct-07 10:26
Hesham Amin27-Oct-07 10:26 
GeneralRe: SQL Express Backup Automated Pin
Paul Conrad27-Oct-07 13:04
professionalPaul Conrad27-Oct-07 13:04 
GeneralRe: SQL Express Backup Automated Pin
Darcy J Williamson27-Oct-07 14:11
Darcy J Williamson27-Oct-07 14:11 

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.