How to get More than 255 characters in a string?
Hello friends::eek:,
I declared array() as string and had array() with values of 281 characters
Quote:
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
Quote:
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?
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
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.
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
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.
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