Saving from a Listbox to a text box.

dave_ie

Member
Joined
Mar 27, 2010
Messages
24
Programming Experience
Beginner
Hi all, i need to Save Items from a List Box to a Text Box,

VB.NET:
 'Saving List Box to a Text file
        Dim w As IO.StreamWriter

        Dim i As Integer
        w = New IO.StreamWriter("Save.txt")
        For i = 0 To ListBox1.Items.Count - 1
            w.WriteLine(ListBox1.Items.Item(i))
        Next
        w.Close()

My Question is how do I also saved the Details of the User that is Logged in as the Details they entered when creating an Account, they are saved in the txtaccount.text

One more thing when the User Creates an Account how do i check if the Email they enters is in Right order that its not Text.@Textcom that it is Text@Text.Com
 
You can validate the email address like this:-

VB.NET:
Public Function ValidEmail(ByVal email As String) As Boolean
        Dim isitvalid As Boolean
        Dim names, name, i, c
        names = Split(email, "@")
        If UBound(names) <> 1 Then
            isitvalid = False
            Return isitvalid
            Exit Function
        End If
        For Each name In names
            If Len(name) <= 0 Then
                isitvalid = False
                Return isitvalid
                Exit Function
            End If
            For i = 1 To Len(name)
                c = LCase(Mid(name, i, 1))
                If InStr("abcdefghijklmnopqrstuvwxyz_-.", c) <= 0 And Not IsNumeric(c) Then
                    isitvalid = False
                    Return isitvalid
                    Exit Function
                End If
            Next
            If Left(name, 1) = "." Or Right(name, 1) = "." Then
                isitvalid = False
                Return isitvalid
                Exit Function
            End If
        Next
        If InStr(names(1), ".") <= 0 Then
            isitvalid = False
            Return isitvalid
            Exit Function
        End If
        i = Len(names(1)) - InStrRev(names(1), ".")
        If i <> 2 And i <> 3 Then
            isitvalid = False
            Return isitvalid
            Exit Function
        End If
        If InStr(email, "..") > 0 Then
            isitvalid = False
            Return isitvalid
            Exit Function
        End If

        isitvalid = True
        Return isitvalid
    End Function

Not really sure what you are trying to accomplish with the ListBox
 
I have the code to save items inside a list box into a text file. But if a user enters into the program and add items into the list box I want to be able to save the items he added in plus the users account details, name, address, email etc. The text file for the user info is called users.txt
 
Yes this it a Windows app, to Run Local.

The Save and Users text file are saved in the Bin Folder of Program.

And it is being used in Form2
 
Could Some one have a look at this and tell me were i am going wrong, on the Log in and maths, please really need this to work

the maths
The Log in
Creating Account,
Checking to See is the email Correct are giving me problems
 

Attachments

  • ProductPage.zip
    135.9 KB · Views: 12
Last edited by a moderator:
Back
Top