Click here to Skip to main content
16,005,339 members
Home / Discussions / Visual Basic
   

Visual Basic

 
QuestionRe: security issue Pin
Tauseef A25-Dec-07 16:08
Tauseef A25-Dec-07 16:08 
GeneralRe: security issue Pin
Dave Kreskowiak26-Dec-07 2:07
mveDave Kreskowiak26-Dec-07 2:07 
QuestionDelegate writing to another form? Pin
cstrader23223-Dec-07 11:45
cstrader23223-Dec-07 11:45 
AnswerRe: Delegate writing to another form? Pin
Paul Conrad23-Dec-07 14:00
professionalPaul Conrad23-Dec-07 14:00 
AnswerRe: Delegate writing to another form? Pin
nlarson1123-Dec-07 15:42
nlarson1123-Dec-07 15:42 
GeneralRelease an app from an appdomain Pin
cstrader23223-Dec-07 9:38
cstrader23223-Dec-07 9:38 
GeneralRe: Release an app from an appdomain Pin
Luc Pattyn23-Dec-07 13:28
sitebuilderLuc Pattyn23-Dec-07 13:28 
Generalerror to save file Pin
bapu288923-Dec-07 7:59
bapu288923-Dec-07 7:59 
Hello every one
I am new in vb.net and i am doing one simple application to save text file, and i have provide choice to display image in picture box but i am not saving image in file file can only save students name,age,class etc but i am haveing problem to save file,but if i dont load image in picture box then it's works fine again i am not saving image in file it's just for selecting image from file

can some one please help me with this

code is some thing like this (for creating profile)

Private Sub btnProfile_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnProfile.Click<br />
        Dim Response As DialogResult<br />
        Dim Age As String<br />
        Dim MyString, MidString, MidString2 As String<br />
        'get first leter in upper case for text box for name <br />
        txtName.Text = StrConv(txtName.Text, VbStrConv.ProperCase)<br />
        If Trim(txtName.Text) = "" Then<br />
            Response = MessageBox.Show("Please enter your name", "Error", MessageBoxButtons.OK, _<br />
            MessageBoxIcon.Error)<br />
            If Response = DialogResult.OK Then<br />
                txtName.Focus()<br />
                Exit Sub<br />
            End If<br />
        End If<br />
        Age = Str(DateDiff("yyyy", DOB, Now))<br />
        Message = "Your profile was created on    " + ((Format(DateTime, "d  MMMM  yyyy") + _<br />
           " at " + Format(DateTime, "hh : mm tt" + ControlChars.Cr)))<br />
        Message += "" + ControlChars.Cr<br />
        Message += txtName.Text + " is  a  student  in  the  " + cboGrade.Text + "  grade " + ControlChars.Cr<br />
        If rdoMale.Checked Then<br />
            Message += "He  is  " + Age + "  years  old" + ControlChars.Cr<br />
        ElseIf rdoFemale.Checked Then<br />
            Message += "She  is  " + Age + "  years  old" + ControlChars.Cr<br />
        End If<br />
        If picStudent.Image Is Nothing Then<br />
            Message += "" + ControlChars.Cr<br />
            Message += "No picture added " + ControlChars.Cr<br />
        Else<br />
            Message += "" + ControlChars.Cr<br />
            Message += "Your picture was also added in your profile" + ControlChars.Cr<br />
        End If<br />
        Response = MessageBox.Show(Message, "Student Profile", MessageBoxButtons.OKCancel, _<br />
        MessageBoxIcon.Information)<br />
        'Add data in to student data file<br />
        Call AddStudentData()<br />
        'Add student name in to cobmobox<br />
        Call AddDataToCombo()<br />
        If Response = DialogResult.OK Then<br />
            Response = MessageBox.Show("Would you like to creat another profile", "New profile", _<br />
            MessageBoxButtons.YesNo, MessageBoxIcon.Question)<br />
            'if cancel then reset form<br />
        ElseIf Response = DialogResult.Cancel Then<br />
            txtName.Text = ""<br />
            cboGrade.SelectedIndex = 0<br />
            txtName.Focus()<br />
            nudDay.Value = 1<br />
            dudMonth.SelectedIndex = 0<br />
            nudYear.Value = 1951<br />
            picStudent.Image = Nothing<br />
            Exit Sub<br />
        End If<br />
        'if new profile and yes then reset form<br />
        If Response = DialogResult.Yes Then<br />
            txtName.Text = ""<br />
            cboGrade.SelectedIndex = 0<br />
            txtName.Focus()<br />
            nudDay.Value = 1<br />
            dudMonth.SelectedIndex = 0<br />
            nudYear.Value = 1951<br />
            picStudent.Image = Nothing<br />
            Exit Sub<br />
        End If<br />
        If Response = DialogResult.OK Then<br />
            txtName.Text = ""<br />
            cboGrade.SelectedIndex = 0<br />
            txtName.Focus()<br />
            picStudent.Image = Nothing<br />
        Else : Me.Close()<br />
        End If<br />
    End Sub


and code for loading image in picture is

Private Sub btnPicture_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPicture.Click<br />
        'load picture of student<br />
        If dlgOpen.ShowDialog = DialogResult.OK Then<br />
            picStudent.Image = Image.FromFile(dlgOpen.FileName)<br />
        End If<br />
    End Sub


and code for saving students profile,display profile and add students name in combo box is like this

Private Sub AddStudentData()<br />
        Dim DataWriter As StreamWriter<br />
        FileName = Trim(txtName.Text) + ".txt"<br />
        DataWriter = File.CreateText("StudentData\" + FileName)<br />
        DataWriter.WriteLine(Message)<br />
        DataWriter.Close()<br />
        cboData.Items.Add(FileName)<br />
<br />
    End Sub<br />
    Private Sub AddDataToCombo()<br />
        cboData.Items.Clear()<br />
        Dim files() As String = Directory.GetFiles(Application.StartupPath + "\StudentData")<br />
        For i As Integer = 0 To files.Length - 1<br />
            cboData.Items.Add(Path.GetFileNameWithoutExtension(files(i)))<br />
        Next<br />
        If files.Length = 0 Then<br />
            cboData.Text = "Empty Student Database"<br />
        Else<br />
            cboData.Text = "Select name to display profile"<br />
        End If<br />
    End Sub<br />
    Private Sub DisplayData()<br />
        Dim DataReader As StreamReader<br />
        DataReader = File.OpenText("StudentData\" + cboData.SelectedItem.ToString + ".txt")<br />
        FileName = DataReader.ReadToEnd<br />
        MessageBox.Show(FileName, "Student Database", MessageBoxButtons.OK, MessageBoxIcon.Information)<br />
        DataReader.Close()<br />
    End Sub


any help please Cry | :((

have a nice X-mas and new year to all

thanks
GeneralRe: error to save file Pin
Paul Conrad23-Dec-07 9:42
professionalPaul Conrad23-Dec-07 9:42 
GeneralRe: error to save file Pin
Dave Kreskowiak23-Dec-07 10:24
mveDave Kreskowiak23-Dec-07 10:24 
GeneralRe: error to save file Pin
Christian Graus23-Dec-07 11:25
protectorChristian Graus23-Dec-07 11:25 
GeneralRe: error to save file Pin
Dave Kreskowiak23-Dec-07 15:26
mveDave Kreskowiak23-Dec-07 15:26 
GeneralRe: error to save file Pin
bapu288927-Dec-07 1:43
bapu288927-Dec-07 1:43 
GeneralRe: error to save file Pin
Dave Kreskowiak27-Dec-07 5:10
mveDave Kreskowiak27-Dec-07 5:10 
GeneralRe: error to save file Pin
bapu288927-Dec-07 7:26
bapu288927-Dec-07 7:26 
GeneralRe: error to save file Pin
Dave Kreskowiak28-Dec-07 19:31
mveDave Kreskowiak28-Dec-07 19:31 
GeneralRe: error to save file Pin
bapu288929-Dec-07 1:53
bapu288929-Dec-07 1:53 
GeneralRe: error to save file Pin
Dave Kreskowiak29-Dec-07 6:35
mveDave Kreskowiak29-Dec-07 6:35 
GeneralRe: error to save file Pin
bapu288929-Dec-07 8:59
bapu288929-Dec-07 8:59 
GeneralClass versus Form sharing Pin
cstrader23223-Dec-07 6:11
cstrader23223-Dec-07 6:11 
GeneralRe: Class versus Form sharing Pin
nlarson1123-Dec-07 7:01
nlarson1123-Dec-07 7:01 
GeneralRe: Class versus Form sharing Pin
cstrader23223-Dec-07 7:28
cstrader23223-Dec-07 7:28 
GeneralRe: Class versus Form sharing Pin
Dave Kreskowiak23-Dec-07 7:42
mveDave Kreskowiak23-Dec-07 7:42 
GeneralRe: Class versus Form sharing Pin
nlarson1123-Dec-07 9:21
nlarson1123-Dec-07 9:21 
GeneralRe: Class versus Form sharing Pin
Dave Kreskowiak23-Dec-07 7:43
mveDave Kreskowiak23-Dec-07 7: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.