|
-
Jun 29th, 2012, 07:25 AM
#1
Thread Starter
Junior Member
How to get More than 255 characters in a string?
Hello friends: ,
I declared array() as string and had array() with values of 281 characters
When there is a conflict between the heart and the brain, let the heart be followed.. A man of intellect can turn into a devil, but never a man of heart. Everything can be sacrificed for truth, but truth can't be sacrificed for anything. There is no misery where there is no want
after i getting the array i tried to print it in another page using typetext option it prints only 255char only like this
When there is a conflict between the heart and the brain, let the heart be followed.. A man of intellect can turn into a devil, but never a man of heart. Everything can be sacrificed for truth, but truth can't be sacrificed for anything. There is no mis
Any suggestion regarding this, How do i get it with the actual range?
-
Jun 29th, 2012, 10:35 AM
#2
Re: How to get More than 255 characters in a string?
what does the code look like? how was the array defined? how was it assigned the values? how are you printing things back out?
-tg
-
Jun 30th, 2012, 03:36 AM
#3
Thread Starter
Junior Member
Re: How to get More than 255 characters in a string?
In my Task i need to sort References in alphabetically. since i get the number of reference count in inputbox, so used it in the definition of Redim, here i posted my code below
Code:
Sub Sortingauthor()
Dim TheInput As String
Dim Authorreference() As String
Dim SortedAuthorreference() As Variant
Dim i As Integer
Dim ReferenceCount As Integer
ReferenceCount = InputBox("Enter the Number of References", "No. of References")
Dim References(1000) As String
ReDim Authorreference(1 To ReferenceCount)
ReDim SortedAuthorreference(1 To ReferenceCount)
Selection.HomeKey unit:=wdStory
With Selection.Find
.text = "^pReferences^p": .Replacement.text = vbnullstring: .Forward = True: .Wrap = wdFindContinue: .Format = False: .MatchCase = False: .MatchWholeWord = True: .MatchWildcards = False: .MatchSoundsLike = False: .MatchAllWordForms = False
End With
Selection.Find.Execute
Selection.MoveRight unit:=wdCharacter, count:=1
For i = 1 To ReferenceCount
Selection.MoveDown unit:=wdParagraph, count:=1, Extend:=wdExtend
Authorreference(i) = Selection.Range.text
Selection.MoveRight unit:=wdCharacter, count:=1
Next i
WordBasic.sortarray Authorreference()
For i = 1 To (UBound(Authorreference()))
SortedAuthorreference(i) = Authorreference(i)
MsgBox (SortedAuthorreference(i))
Next i
End Sub
After sorting the array if it exceeds 255characters it wont print properly.
-
Jun 30th, 2012, 07:31 AM
#4
Re: How to get More than 255 characters in a string?
does it print correctly if you print from the array before sorting?
this would appear to be a limitation of wordbasic.sortarray, try some other sorting alogrithm
there are many examples of bubblesort and quicksort, in these forums, that should work for you
i do my best to test code works before i post it, but sometimes am unable to do so for some reason, and usually say so if this is the case.
Note code snippets posted are just that and do not include error handling that is required in real world applications, but avoid On Error Resume Next
dim all variables as required as often i have done so elsewhere in my code but only posted the relevant part
come back and mark your original post as resolved if your problem is fixed
pete
-
Jul 2nd, 2012, 03:51 AM
#5
Thread Starter
Junior Member
Re: How to get More than 255 characters in a string?
Thank U westconn1, you are correct it is only because of wordbasic.sortarray command. After using temp variable for sorting it works perfectly.
Last edited by Deepakgopikannan; Jul 2nd, 2012 at 03:56 AM.
-
Jul 2nd, 2012, 03:52 AM
#6
Thread Starter
Junior Member
Re: How to get More than 255 characters in a string?
Code:
Private Sub Sortusingtemp(Authorreference() As Variant)
Dim SortedAuthorreference() As Variant
Dim First As Integer
Dim Last As Integer
Dim i As Integer
Dim j As Integer
Dim Temp As String
Dim List As String
First = LBound(Authorreference)
Last = UBound(Authorreference)
For i = First To Last - 1
For j = i + 1 To Last
If Authorreference(i) > Authorreference(j) Then
Temp = Authorreference(j)
Authorreference(j) = Authorreference(i)
Authorreference(i) = Temp
End If
Next j
Next i
End Sub
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|