Results 1 to 2 of 2

Thread: Real Basic Function problems

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Feb 2008
    Posts
    17

    Real Basic Function problems

    Hello all, it has been a while since I have posted here. Recently I purchased real basic and began programming in it today, the move from VB to RB should be easy I have been told and so far it has been easy then I encountered writing a function. The program I was asked to develop was fairly simple take in data, validate the data and then have it worked out using length*breadth*height/pupils.

    My problem is basically End Function doe snot end the function instead I am told "Not found exception". I am sorry if this post seems a bit over the place.

    Here is my coding:

    Code:
      Dim height As Single
      Dim length As Single
      Dim breadth As Single
      Dim volume As Single
      Dim airspace As Single
      Dim studnets_allowed As Integer
      
      height = getValidNumber (2, 5)
      length = get ValidNumber (4, 10)
      breadth =  getValidNumber (4, 10)
      airspace = GetValidResponse
      
      volume = height * length * breadth
      students_allowed = Int (volume / airspace)
      
      MsgBox ("Students allowed " & students_allowed)
      
      End Sub
      
      Function getValidNumber (Min, Max As Single) As Single
        Dim Num As Single
        Dim NumberOK As Boolean
        NumberOK = false
        Do
          Num = InputBox("Enter a number between " & Min & " and " & Max
          If Num >= Min and Num <= Mac Then NumberOK = True
          If Not NumberOK Then MsgBox ("That was not in the valid range")
        Loop until NumberOK
        getValidNumber = Num
      End Function
      
      Function GetValidResponse()As String
        Dim response As Single
        Dim responseOK As Single
        responseOK = False
        Do 
          response = InputBox 9"Airspace per student  . Either 2.1 or 3.2")
          If (response) =  "2.1" Or (response) = "3.2" Then responseOK = True
          If Not responseOK Then MsgBox 9"That was not a valid amount of airspace ")
        Loop Until responseOK = True
        GetValidResponse = response
      End Function
    I ahve place the coding which has been creating the difficulty in question in bold.

    All assistance offered would be great.

    Thanks,
    Colin

  2. #2
    Addicted Member
    Join Date
    Oct 2004
    Location
    Clane, Ireland
    Posts
    179

    Re: Real Basic Function problems

    Hi, you've probably solved this by now but just in case.........

    First of all I'm about to start using Real Basic, so am no expert but in your second function, your InputBox line had a 9 instead of an open bracket - is this a typo, or could this be your problem? Same with the MSGBOX line.

    The other thing I notice is that you have defined GetValidResponse as a string, but you set it equal to a single (reponse is defined as a single).

    HTH

    JP
    JP

    Please rate the postings

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