Question Use a form again and again

dan_score

Member
Joined
Jun 24, 2008
Messages
11
Programming Experience
1-3
Is there a way to take a form in a desired format, and copy it, to use it again, instead of making the same basic layout each time? Im making a program for my father, and he wants to have a program where people answer questions one at a time, and the forms will all have the same layout. Its annoying to keep remaking a form that looks the exact same. I have visualbasic 2008 express edition
 
you can create a baseform with the desired layout and then inherit from it.....have you looked into that?
 
Where are the questions going to be stored? If they are in a database or possibly in an array you could just use the same form and load the different questions into labels, then you only would have to worry about one form.
 
keeping text in paragraph format

Im using an array to store info in. The questions i am feeding into questionsns into the textbox/label that are more than one paragraph long. the type of code im using is
txtQuestion.text = "the question goes here, and it is in many paragraphs"

if there is a different way to do what im doing that will keep the questions in nice paragraph form, that would be great.

Thanks Much, Dan
 
You could use a rich text box. It has a readonly property that you can set to true and then the users cannot interact with the questions.
 
by paragraph form do you mean do you mean indented and such:
VB.NET:
     We provide such information to our subsidiaries, affiliated companies or 
other trusted businesses or persons for the purpose of processing personal 
information on our behalf. We require that these parties agree to process 
such information based on our instructions and in compliance with this Policy 
and any other appropriate confidentiality and security measures. 

     We have a good faith belief that access, use, preservation or disclosure 
of such information is reasonably necessary to (a) satisfy any applicable law, 
regulation, legal process or enforceable governmental request, (b) enforce 
applicable Terms of Service, including investigation of potential violations 
thereof, (c) detect, prevent, or otherwise address fraud, security or 
technical issues, or (d) protect against imminent harm to the rights, property 
or safety of Google, its users or the public as required or permitted by law.

a rich text box will handle that.

VB.NET:
rtbQuestion.Text = ControlChars.Tab & " Start of  a paragraph, indented by tab character. End of line one." & Environment.NewLine & "This will be the start of the next line, not indented."
 
here's a very basic questionaire form utilizing : 4 buttons and 2 richtextboxes

VB.NET:
Public Class QandA

    Dim aryQuestions(14) As String
    Dim aryAnswers(14) As String
    Dim QuestionAnswerPosition As Integer = 0


   
    Private Sub QandA_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        'set default to the first question 
        QuestionAnswerPosition = 0

        'fill questions
        FillQuestions()

        'load initial question/answer
        LoadQuestionAnswer()
    End Sub


    Private Sub btnClose_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnClose.Click
        Me.Close()
    End Sub

    Private Sub btnNext_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnNext.Click
        If QuestionAnswerPosition + 1 > aryQuestions.GetUpperBound(0) Then
            QuestionAnswerPosition = 0
        Else
            QuestionAnswerPosition += 1
        End If

        'loads next questin/answer
        LoadQuestionAnswer()

    End Sub

    Private Sub btnPrev_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPrev.Click
        If QuestionAnswerPosition - 1 < aryQuestions.GetLowerBound(0) Then
            QuestionAnswerPosition = aryQuestions.GetUpperBound(0)
        Else
            QuestionAnswerPosition -= 1
        End If

        'loads previous question/answer
        LoadQuestionAnswer()

    End Sub


    Private Sub btnReset_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnReset.Click
        'clears all the answers
        Array.Clear(aryAnswers, 0, aryAnswers.Length)

        'reset the postion to beginning of the questions
        QuestionAnswerPosition = 0

        'reload the questions
        LoadQuestionAnswer()
    End Sub

    Private Sub LoadQuestionAnswer()

        rtbQuestion.Text = aryQuestions(QuestionAnswerPosition)

        rtbAnswer.Text = aryAnswers(QuestionAnswerPosition)

    End Sub

    Private Sub FillQuestions()

        For intQuestionCnt As Integer = 0 To 14
            aryQuestions(intQuestionCnt) = "This is question number " & intQuestionCnt & "?"
        Next
    End Sub

    Private Sub rtbAnswer_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles rtbAnswer.TextChanged
        aryAnswers(QuestionAnswerPosition) = rtbAnswer.Text
    End Sub
End Class
 
Back
Top