Begginnerdev 256 Junior Poster

Also, if you are simply wanting to copy one file from one location to another, you can use this call:

    Dim outFileName As String = "myTXT.txt"
    Dim input As String = My.Computer.FileSystem.SpecialDirectories.Desktop & "\myTXT.txt"
    Dim output As String = My.Computer.FileSystem.SpecialDirectories.Desktop & "\TEST\" & outFileName

    If IO.File.Exists(input) Then
        If IO.Directory.Exists(output.TrimEnd.TrimEnd(outFileName.ToCharArray)) = False Then
            If MsgBox("Directory does not exist:" & vbCrLf & output.TrimEnd(outFileName.ToCharArray) & vbCrLf & "Do you want to create it?", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
                IO.Directory.CreateDirectory(output.TrimEnd(outFileName.ToCharArray))
                IO.File.Copy(input, output)
            End If
        Else
            IO.File.Copy(input, output)
        End If
    Else
        MsgBox("Could not find file specified:" & vbCrLf & input & vbCrLf & "Process aborted!")
        Exit Sub
    End If

This will make an exact copy.

Begginnerdev 256 Junior Poster

An IP with the prefix octet of 192 is always a private IP Address.

You will have to assign the server a static (unchanging) ip for outside users to be able to connect.

Here is some material for you to read/research.

Begginnerdev 256 Junior Poster

You will want to look into this.

Begginnerdev 256 Junior Poster

Here is an article that may help you.

Begginnerdev 256 Junior Poster

You will have to add the dll reference to your project, import it, instantiate a variable of the form's class, and then call the forms Show() sub.

Begginnerdev 256 Junior Poster

The all mighty Google, my friend. :)

Begginnerdev 256 Junior Poster

You will want to make use of the FullName property.

Example:

   Dim di As New IO.DirectoryInfo(YourDirectoryHere)
   Dim diar1 As IO.FileInfo() = di.GetFiles()
   Dim dra As IO.FileInfo

   For Each dra In diar1
      If dra.Extension = ".csv" Then
          fileCreatedDate = File.GetCreationTime(dra.FullName) 
      End If
   Next
Begginnerdev 256 Junior Poster

You can do something like this:

   Dim di As New IO.DirectoryInfo(YourDirectoryHere)
   Dim diar1 As IO.FileInfo() = di.GetFiles()
   Dim dra As IO.FileInfo

   For Each dra In diar1
       If dra.Extension = ".csv" Then      
           'Do Work
       End If
   Next
Begginnerdev 256 Junior Poster

I think this is probably what you want.

Begginnerdev 256 Junior Poster

Make use of the sender object of the form.

You can cast the sender to the type of your control.

  Dim cntrl As New Type
  cntrl = TryCast(Sender,Type)
Begginnerdev 256 Junior Poster

Could also do something like this:

For Each line As String in System.IO.File.RealAllLines("input.txt")
    Dim lstData As New List of String
    lstData = line.Split(vbTab).ToList

    For i = 0 To lstData.Count - 1
        outFile.WriteLine(lstData(i))
    Next
Next
Begginnerdev 256 Junior Poster

You can split the contents of the textbox, storing them in list (of string) and remove the element, then rebuild the string.

Example:

    Dim str As New List(Of String)

    'Assuming you are using a , seperator.
    str = TextBox1.Text.Split(",").ToList

    str.Remove("test")

    For i = 0 To str.Count - 1
        If i < str.Count - 1 Then
            TextBox1.Text &= str(i) & ","
        Else
            TextBox1.Text &= str(i)
        End If
    Next

    'When "This,is,a,test,string is passed into - "This,is,a,string" will be returned.
Begginnerdev 256 Junior Poster

Something like this would do the trick:

"INSERT INTO destinationTable(Itemname,Itemcode)" & _
  "SELECT sourceTable.ItemName, sourceTable.ItemCode " & _
   "FROM sourcetable WHERE sourcetable.Column=Value"
Begginnerdev 256 Junior Poster

Try this:

Dim lstCourses As New List(Of Course)

This will create a list, you can add and remove elements like this:

lstCourses.Add(Courses1)
lstCourses.Remove(Courses1)
Begginnerdev 256 Junior Poster

Use a masked text box. Just set the mask and it will do the rest for you.

Example

Begginnerdev 256 Junior Poster

No problem my friend. Just be sure to marked the thread as solved.

Thank you for chosing Daniweb. :)

Begginnerdev 256 Junior Poster

Have you stepped through the code to make sure it is executing the query?

You can also try to create a new instance of cmd every command (what I use)

   cmd = New System.Data.OleDb.OleDbCommand("INSERT INTO [GrindItems] ( EMPLOYEE, CHECK, ITEM, PARENT, CATEGORY ) " & _
                                                " VALUES(" & _
                                                ds.Tables(0).Rows(iX).Item(1) & "," & _
                                                ds.Tables(0).Rows(iX).Item(2) & "," & _
                                                ds.Tables(0).Rows(iX).Item(3) & "," & _
                                                ds.Tables(0).Rows(iX).Item(4) & "," & _
                                                ds.Tables(0).Rows(iX).Item(5) & ")",yourConnection)
Begginnerdev 256 Junior Poster

Handle the listview's Click event

Example:

    Private Sub ListView1_Click(sender As System.Object, e As System.EventArgs) Handles ListView1.Click
    'Refernces the selected record
    Try
        If IsNothing(ListView1.SelectedItems) = False Then
            For Each sItem As ListViewItem In ListView1.SelectedItems
                If sItem.Subitem(3).Text.ToLower() = "fail" Then
                    MsgBox("Failing grade!")
                End If
            Next
        End If
    Catch ex As Exception
        MsgBox("There was a problem referencing the entry!" & vbCrLf & ex.Message)
    End Try
End Sub
Begginnerdev 256 Junior Poster

Also, what might be a problem - When inserting strings, you will have to wrap the value in ''

Example:

cmd.CommandText = "INSERT INTO [GringItems] (EMPLOYEE,CHECK,ITEM,PARENT,CATEGORY)" & _
                        " VALUES ('" & _
                        ds.Tables(0).Rows(iX).Item(1) & "'," & _
                       'ect...

You will only need to wrap the values that are represented as string

Begginnerdev 256 Junior Poster

Have you tried to cast it to the data type of Date?

Begginnerdev 256 Junior Poster

If the declaration is in anything private than it is in accessable.

Can you post the bit of code for the declaration?

Begginnerdev 256 Junior Poster

The best solution would be to check for a forum for the addin.

Something the developer uses for a "tech support" web site.

As for vb.net, you may have problems going from LTR languages to RTL languages and visa versa.

Begginnerdev 256 Junior Poster

Are you using data encapsulation or just sending to Module1's public variable?

(Encapsulation would be using public Properties)

Example:

'Declare local variable
Private iBill as Integer


Public Property CurrentBill as Integer
    Get
        Return me.iBill
    End Get
    Set (value as Integer)
        Me.iBill = Value
    End Set
End Property

-Or-

You can try the following:

Dim bill As Integer = TryCast(textbox14.text,Integer)
If IsNothing(bill) = False Then
    Module1.billno = bill
Else
    MsgBox("Cast not successful")
End If
Begginnerdev 256 Junior Poster

You need to make use of the sender object.

Example:

Private Sub Button_Click(sender as System.Object, e as System.EventArgs)
    Try
        Dim ST As New Button

        ST = TryCast(sender,button)

        ST.BackColor.ToString = TextBox1.Text
    Catch
        MsgBox(ex.message)
    End Try
End Sub

Programaticly add this handler to each button ( To rid yourself of the long line of handles clauses )

Example:

For Each btn as Button in Me.Controls
   AddHandler btn.Click, AddressOf Button_Click
Next

'Assuming those buttons are the only ones that exist.

Hope this helps.

Begginnerdev 256 Junior Poster

Try this instead:

For remove use the following:

listview6.Items.Remove(listview6.SelectedItems.Item(0))

'If multiple items are selcted use

For each itm as ListViewItem in ListView6.SelectedItems
    listview6.Items.Remove(itm)
Next
Begginnerdev 256 Junior Poster

G Waddell's suggestion is the quickest way to do what you are wanting.

Begginnerdev 256 Junior Poster

I concur with Pgmer.

There are many resouce out there for threading/background workers.

Example:

Click here for threading

or

Click here for background worker

Begginnerdev 256 Junior Poster

You can also create one function using Jim's method:

Private Sub FocusChanged(sender As Object, e As EventArgs)

    If CType(sender, TextBox).Focused = True Then
        CType(sender, TextBox).BackColor = Color.FromArgb(65, 65, 65)
    ElseIf CType(sender, TextBox).Focused = False Then
        CType(sender, TextBox).BackColor = Color.FromArgb(60, 60, 60)
    End If

End Sub

And just add the handlers to each textbox:

'Add this code in the form load event'

For Each txt As TextBox In Me.Controls
        AddHandler txt.GotFocus, AddressOf FocusChanged
        AddHandler txt.LostFocus, AddressOf FocusChanged
Next
iFrolox commented: Thank you +2
Begginnerdev 256 Junior Poster

I am sorry my friend, but I believe you have posted on the wrong forum.

This is, in fact, the VB.NET forum.

I will flag for a mod to transfer for you.

Begginnerdev 256 Junior Poster

Problem 1:

If you are seperating the values with ','; then you can make use of the string split function (asuming all values will be in the same format.)

Just pass in the string from the listbox and then parse the string into an array using string split.

Example:

 Dim ar() As String = Split(ListBox1.SelectedItem, ",")
'This will return something that looks like this'
'String: Chocolate, 10, 24.55'
' ar(0): Chocolate'
' ar(1): 10'
' ar(2): 24.55'

Problem 2:

You should make use of the sender object that is passed in.

You will have to use CType(sender, Form) to manipulate the form from another.

Example:

   Dim callingForm As Form = CType(sender, Form)
   Dim FormName As String = callingForm.Name

Hope this helps!

Begginnerdev 256 Junior Poster

I have not tried it before, but you can make use of ReDim Preserve.

You can recreate the array every time it is needed.

iFrolox commented: And what i needed to finish, thx :) +0
Begginnerdev 256 Junior Poster

You could try something like:

Dim curItem as Integer = 3
ar.RemoveAt(3)
For i = CurItem to ar.Count - 2
    ar(i) = ar(i + 1)
Next

ar.RemoveAt(ar.Count - 1)

This will "push" everything up one, then delete the last one.

iFrolox commented: Really important, i needed this, thank you +0
Begginnerdev 256 Junior Poster

You have alot of over head here I see.

Is using a database out of the question?

If it is, then what about using an ArrayList?

When using an array list, you can simply store each account in the ArrayList and remove one by:

Dim ar As New ArrayList
Dim index As Integer = 3
ar.RemoveAt(index) 'This will remove the fourth entry.'

This will remove the account at the fourth entry in the array.

You will need to cast to the account type when using arraylists too.

Example:

Dim refAccount as Accounts


refAccount = TryCast(ar(0),Accounts)

If refAccount IsNot Nothing Then
    'Cast was successfull. Continue working'
Else
    'Cast was unsuccessfull. Halt application or implement fault tolerance.'
End If
Begginnerdev 256 Junior Poster

You can do something like this:

    Dim itm As ListViewItem
    Dim total As Single
    For Each itm In ListView1.Items
        If itm IsNot Nothing Then
            For i = 0 To itm.SubItems.Count - 1
                total += CSng(itm.SubItems.Item(i).ToString)
            Next
            itm.SubItems.Add(total)
        End If
    Next

See if this works.

Begginnerdev 256 Junior Poster

You can try placing an IIF into the lines to test against empty or null values.

Example:

    objWriter.WriteLine(" <Update Name='SH_REQ_DEL_DATE' Value= '" & IIf(sqlReader.GetString(0), IsNothing(sqlReader.GetString(0)) = False, IsNothing(sqlReader.GetString(0)) = True) & "'/>")
Begginnerdev 256 Junior Poster

When you say that it refreshes the workbooks, are you meaning it updates data with current data and then saves as a different workbook?

Are you using the original workbook as a template, or as a backup for the previously updated data?

Begginnerdev 256 Junior Poster

Place this in the form's load event:

    Me.Width = Screen.PrimaryScreen.Bounds.Width - 20
    Me.Height = Screen.PrimaryScreen.Bounds.Height - 20
Begginnerdev 256 Junior Poster

Carrige return line feeds. It reperesents the new line character, aka the enter button.

You will have to read the data in the file one char at a time and pull in what you will need.

Begginnerdev 256 Junior Poster

If your paragraphs are seperated by Crlf's, you can count the number of Clrf's between two sentences to determin a new paragraph.

You will have to read the character before the current character and possibly the character before that too.

You will want to do this by reading the file in character by character.

Begginnerdev 256 Junior Poster

Are you receiving any errors, or is the database just not getting updated?

Begginnerdev 256 Junior Poster

Are you appending the data that is in memory back out the file? If so you are just adding everything back in again.

Example:

If you are reading into table > add more to end > post back out = Post all data in table, including data that is already in the workbook.

You can compare line by line to the table to see if the data is already in the workbook, if so, don't add it and visa versa.

Begginnerdev 256 Junior Poster

This does something very close to what you want, try to use this as a reference.

    Dim j As Integer = CInt(TextBox1.Text)
    Dim numOfPasses As Integer = j

    Dim numbers() As String = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"}


    For i = 0 To j
        Dim lineString As String = ""
        numOfPasses = i + 1
        While numOfPasses <> 0
            lineString &= numbers(numOfPasses)
            numOfPasses -= 1
        End While
        ListBox1.Items.Add(lineString)
    Next
kiyu2keith commented: thanks, it helped a lot +0
Begginnerdev 256 Junior Poster

You will need to make use of the Microsoft Office Interopt libraries if you are wanting to manipulate a workbook that is not open.

Begginnerdev 256 Junior Poster

Yep, if you want to check all of the radio buttons at once (Only allowing one answer/click) you will want to do the follwing:

AddHandler RadioButton1.Click, AddressOf RBC
AddHandler RadioButton2.Click, AddressOf RBC
AddHandler RadioButton3.Click, AddressOf RBC
AddHandler RadioButton4.Click, AddressOf RBC

Then place the IF code in the RBC Sub, checking for which radio button was clicked.

To check which control sent the action, make use of the sender object.

Begginnerdev 256 Junior Poster

You will need to create the sub for the click and then add the handler on runtime.

Example:

AddHandler RadioButton1.Click, AddressOf RBC

Private Sub RBC(sender As Object, e As EventArgs)
    'Place code here
End Sub
Begginnerdev 256 Junior Poster

Use the command to fill a data adapter, and port that into a data table.

Then cycle through the data table and pass those values in.

Example:

    Dim da As New SqlDataAdapter
    Dim ds As New Data.DataSet
    Dim dt As New Data.DataTable

    da.SelectCommand = MyCommand
    da.Fill(ds, "myitems")
    dt = ds.Tables("myitems")

    For i = 0 To dt.Rows.Count - 1
        message.Body &= vbCrLf & dt.Rows(i).ToString
    Next
Begginnerdev 256 Junior Poster

What you will need to do is:

1) Loop through the workbook, comparing and storing all values that reference that person.
2) Loop through those values, adding them to the message (body?)**

It may be easier to write the values to a text file and attach the text file to the message.

Begginnerdev 256 Junior Poster

Sure, if you don't mind.

Begginnerdev 256 Junior Poster

What form border style are you using?

I know I have had some issues when desinging in Sizable and then changing it to Fixed3D ect..

Are these controls placed inside another? ie. Panel, Groupbox ect..

Begginnerdev 256 Junior Poster

Do you have any code in the form's resize event or any code anywhere that changes their location?

Also, is the screen resolution any different when debugging/release?