Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

delimiters Help in VB6 1

Status
Not open for further replies.

Sammy145

Programmer
Oct 4, 2002
173
GB
I have a file with delimiters ROW and Coloumn

~43434^^1^^here^^Somedescription
~11111^^2^^SOme^^testdescription

I want to insert this into a sql server 2000 table
ProdID varchar(7)
EMPIDvarchar(7)
ttext varchar(50)
description varchar(255)

I know how to open the file the problem is doing an array and reading in Row and coloum delimiter.
Can someone HELP PLZ
 
Look into the split function. It can split a string into an array on any deliminater you choose. Thanks and Good Luck!

zemp
 
Can't you split twice if you need to. Split the file into an array of rows. Then when you are inserting a row split the row into columns to properly insert a record. Thanks and Good Luck!

zemp
 

Then use the Replace function on the string first, replacing the double char with something like a pipe symbol.
Then...use the Split function with the new delimiter. [/b][/i][/u]*******************************************************
General remarks:
If this post contains any suggestions for the use or distribution of code, components or files of any sort, it is still your responsibility to assure that you have the proper license and distribution rights to do so!
 

Who said split can only split on one character? ...
[tt]
Option Explicit

Private Sub Command1_Click()
Dim S As String, MyArray() As String, I As Integer

S = "~43434^^1^^here^^Somedescription"

MyArray = Split(S, "^^")

For I = LBound(MyArray) To UBound(MyArray)
Debug.Print MyArray(I)
Next I

End Sub
[/tt]
or
[tt]
Option Explicit

Private Sub Command1_Click()
Dim S As String, MyArray() As String, I As Integer, A As Integer, MyAry() As String

S = "~43434^^1^^here^^Somedescription~11111^^2^^SOme^^testdescription"

MyAry = Split(S, "~")

For A = LBound(MyAry) To UBound(MyAry)
MyArray = Split(MyAry(A), "^^")

For I = LBound(MyArray) To UBound(MyArray)
Debug.Print MyArray(I)
Next I

Next A

End Sub
[/tt]

Good Luck

 
I think the idea concerning the limitation of the delimiter in the Split function was perpetrated by the VB documentation, which says that the delimiter is a "string character [singular; my emphasis] used to identify substring limits".
 

Oh I agree! I was just being a Smart, Oh, ah, er, full of, ... sarcastic! Yes thats the word, Sarcstic.

It's amazing how giddy one can get with out much sleep.

Yes, some times the documentation by ms leaves much to be desired...
 
thanks guys
esp vb5prgrmr ok i want to verify that first and second items in this loop is numeric how can this be done

I am very new to Vb and wouldl like to thank you for spending your time helping me

Sam
 
what is considered numeric?...

only:
1234567890

or:
-12345.67890

...Just out of curiosity...

...AND...

???No Reg Exp for this???
[lol][rofl][lol]
J/K Sometimes... the BASIC things in life are the best...
cheers.gif

or at least the most fun ;-)
-Josh Stribling
 
Both are considered numeric. Or at least the isnumeric function will return true for both. Thanks and Good Luck!

zemp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top