Results 1 to 6 of 6

Thread: How to get More than 255 characters in a string?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Mar 2012
    Posts
    22

    Red face 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?

  2. #2
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    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
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Mar 2012
    Posts
    22

    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.

  4. #4
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    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

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Mar 2012
    Posts
    22

    Thumbs up 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.

  6. #6

    Thread Starter
    Junior Member
    Join Date
    Mar 2012
    Posts
    22

    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
  •  



Click Here to Expand Forum to Full Width