fill a datagrid with cvs in resource

fill a datagrid with cvs in resource

^_^clovis^_^
Advocate Advocate
482 Views
4 Replies
Message 1 of 5

fill a datagrid with cvs in resource

^_^clovis^_^
Advocate
Advocate

Hello,

I'm trying to build an addin to help the drafter to select a thickness of gauge plate using this info.

In Europe we usually don't use them until now.

I'll keep the datagrid invisible and select the gauge through a combobox. A label2 will give the dimension info.

I have in my Resources a vcs file having within

index,gauge,inch,mm (1st line is 1,0000000,0.5,12.7)

I have on a form a dataGrid with 4 columns

I'd like to use this vcs to fill a datagrid with but I don't know how to do that.

 

Could someone put me on the right track?

Thanks

 

INV2014

with vb2010Express

 

 

 

0 Likes
483 Views
4 Replies
Replies (4)
Message 2 of 5

bshbsh
Collaborator
Collaborator

If i understood correctly, you want something like this?

Public Sub CSVtoComboBox()
    Dim FSO As Object
    Dim CSVFile As String
    Dim Delim As String
    Dim ComboBox As ComboBox
    Set ComboBox = UserForm1.ComboBox1 'Your comboBox
    Delim = ","
    Set FSO = New FileSystemObject
    CSVFile = "D:\Path\To\Your\File\CSVfile.csv"
    If FSO.FileExists(CSVFile) Then
        Dim TStream As TextStream
        Set TStream = FSO.OpenTextFile(CSVFile)
        Dim DataRow() As String
        While Not TStream.AtEndOfStream
            DataRow = Split(TStream.ReadLine, Delim)
            ComboBox.AddItem
            ComboBox.List(ComboBox.ListCount - 1, 0) = DataRow(0)
            ComboBox.List(ComboBox.ListCount - 1, 1) = DataRow(1)
            ComboBox.List(ComboBox.ListCount - 1, 2) = DataRow(2)
            ComboBox.List(ComboBox.ListCount - 1, 3) = DataRow(3)
        Wend
        TStream.Close
        Set TStream = Nothing
    End If
End Sub
0 Likes
Message 3 of 5

^_^clovis^_^
Advocate
Advocate

Hello Bshbsh,

Thanks for the info. I can't use it directly as I get a lot of errors but I can use it, I hope as guide line.

I suppose that you're not using vb2010.

 

FilesystemObject

As TextStream

TStream.AtEndOfStream

 

give an error

 

To open the Form1 I've put in my macro the following

Form1.ActiveForm.BringToFront()
Form1.ActiveForm.Activate()

but nothing happens.

For this one I also can't find any lead to how to call a Form from a sub.

Any idea?

To solve all that I'll make a new project and put bit by bit new element in my addin.

Thanks for any idea

 

 

0 Likes
Message 4 of 5

bshbsh
Collaborator
Collaborator

oops, sorry, i missed the vb2010 part. i've no clue about that, i'm just using vba.

0 Likes
Message 5 of 5

^_^clovis^_^
Advocate
Advocate

With the great help of Adam Nagy

KUDO'S!!!

http://modthemachine.typepad.com/my_weblog/2010/02/custom-iproperties-dialog.html

and other great programmers I finally get my adding working.

I still need to do some research to insert a button to the right Panel but it works.

To call a Dialog it's as simple as

 Private Sub m_buttonDef_OnExecute(ByVal Context As Inventor.NameValueMap) Handles m_buttonDef.OnExecute
            Dim dialog As New Test7Dialog
            dialog.ShowDialog()
        End Sub
0 Likes