Wrox Home  
Search P2P Archive for: Go

  Return to Index  

asp_databases thread: Divide long text in half


Message #1 by Marios Adamantopoulos <mario@T...> on Wed, 21 Mar 2001 11:18:31 -0000
Hi all,



I have a memo field in an Access database,

and I would like to pull that, and divide it in

half and half. So if I have 200 hundred words

100 go to one column of a table and other 100 to other column of a table.



Anyone can help?



Thanks



Mario



_____________________

Marios Adamantopoulos

Web Developer



Message #2 by "yuenkit" <janet_smith2000@y...> on Wed, 21 Mar 2001 15:21:58
<%

'=====METHOD 1: If u want to put (1_Michael, 3_Ali, 5_Dino) into 1 column 

and the rest into another=====

'-----Type Declaration-----

Dim strText, arrText

Dim strColumn1, strColumn2, intNo



'-----Separate The Words-----

strText = "1_Michael, 2_Johnson, 3_Ali, 4_Bapa, 5_Dino"

arrText = Split(strText, ", ")



intNo = 0

For Each objItem in arrText

	if (intNo Mod 2 = 0) Then

		strColumn1 = strColumn1 & objItem & ", "

	Else

		strColumn2 = strColumn2 & objItem & ", "

	End If

	intNo = intNo + 1

Next



strColumn1 = Left(strColumn1, Len(strColumn1) - 2)

strColumn2 = Left(strColumn2, Len(strColumn2) - 2)



Response.Write strColumn1 & "<br>"

Response.Write strColumn2 & "<br>"



strSQL = "INSERT INTO table_name(column_1, column2) VALUES(strColumn1, 

strColumn2);"

%>

<%

'=====Method 2: if u wanna group the 1st, 2nd, 3rd values into 1 column 

and the rest into another column, try this=====

'-----Type Declaration-----

Dim intNoOfWord

Dim strText1, arrText1

Dim intMaxWord

Dim intNoDivide

Dim intNoWord

Dim strCol1, strCol2



'-----Separate The Words-----

strText1 = "1_Michael, 2_Johnson, 3_Ali, 4_Bapa, 5_Dino"

arrText1 = Split(strText, ", ")



intMaxWord = UBound(arrText1) 

intNoDivide = Round(UBound(arrText1) / 2, 0)



strColumn1 = ""

strColumn2 = ""



For intNoWord = 0 To intMaxWord

	If intNoWord <= intNoDivide Then

		strCol1 = strCol1 + arrText1(intNoWord) & ", "

	Else

		strCol2 = strCol2 + arrText1(intNoWord) & ", "

	End If

Next



strCol1 = Left(strCol1, Len(strCol1) - 2)

strCol2 = Left(strCol2, Len(strCol2) - 2)



Response.Write strCol1 & "<br>"

Response.Write strCol2 & "<br>"



strSQL = "INSERT INTO table_name(column_1, column2) VALUES(strCol1, 

strCol2);"

%>



> Hi all,

> 

> I have a memo field in an Access database,

> and I would like to pull that, and divide it in

> half and half. So if I have 200 hundred words

> 100 go to one column of a table and other 100 to other column of a table.

> 

> Anyone can help?

> 

> Thanks

> 

> Mario

> 

> _____________________

> Marios Adamantopoulos

> Web Developer

> 


  Return to Index