how to declare form textbox in vb module

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tshukela
    New Member
    • Feb 2013
    • 2

    #1

    how to declare form textbox in vb module

    I have a module with an array, so I want the results of an array to be displayed in a form textbox.

    When I'm trying to use the texbox in a module a get an error that reads "Error'text box' is not declared. It may be inaccessible due to its protection level.", so how do I solve this problem?
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    We would need to see the code.

    Comment

    • tshukela
      New Member
      • Feb 2013
      • 2

      #3
      here are my codes

      Code:
      Module Module1
          Sub AddCourse(ByVal Team As String, ByRef ReturnString As String)
              Dim Subjects() = {"Ms Office 2007", "internet and commmunications", "Lifetime skills"}
              
              Dim CourseName As String = ""
              Dim Result As String
              Dim i As Short
              Dim Title As String
      
      
      
      
              Dim Prompt, Mn, WrapCharacter As String
              Prompt = "Enter registred Course." & Team
              Mn = InputBox(Prompt, "input box")
              WrapCharacter = Chr(13) + Chr(10)
              ReturnString = Mn & WrapCharacter
      
      
              If Mn = "computer literacy" Then
                  Result = "Student is registered for Course name " & CourseName & vbCrLf & vbCrLf
                  For i = 0 To UBound(Subjects) ' FOR LOOP TO WRITE AN ARRAY
                      Title = "Subject = " & (i + 1)
      
                      Result = Result & "Subject = " & (i + 1) & vbTab & _
                                  Subjects(i) & vbCrLf
      
      
                  Next
                 
              Else
                  MsgBox("Enter computer literacy")
      
              End If
          End Sub
      Last edited by Rabbit; Feb 7 '13, 05:05 PM. Reason: Please use code tags when posting code.

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        And which line causes the error?

        Comment

        • IronRazer
          New Member
          • Jan 2013
          • 83

          #5
          Hey tshukela,
          I do not see any call to send anything to a textbox but, if i am understanding correct you want to send the (Result) string to a textbox on your form from within the module. If so you could try this :

          1. Replace (Form1) with the name of your form that has the textbox on it.
          2. Replace (Textbox1) with the name of your textbox.
          3. Make sure your textbox (Multiline) property is set to True.

          Code:
                  For i = 0 To UBound(subjects) ' FOR LOOP TO WRITE AN ARRAY
                      result = result & "Subject = " & (i + 1) & vbTab & subjects(i) & vbCrLf
                  Next
                  Form1.TextBox1.Text = result

          Comment

          Working...