1. *** New version of B4J is available ***
    B4J v7.8
    Dismiss Notice

Object Reference not set to an instance of an object

Discussion in 'Questions (Windows Mobile)' started by monster9999, Jan 13, 2008.

  1. monster9999

    monster9999 Member


    i´ve got a problem with adding events

    my code:

    for example: I want to add a Scroolbar ("ScroolBar1") on a TabControl (tbc2)

    ' Create
    ScrollBar1.Maximum = 110
    ScrollBar1.Minimum = 0
    'Add ScroolBar1 on tabControl


    Sub ScrollBar1EventValueChanged
    tbc2Label1.Top = 15 - ScrollBar1.Value
    tbc2Label2.Top = 27 - ScrollBar1.Value
    tbc2Label3.Top = 59 - ScrollBar1.Value
    tbc2Label4.Top = 91 - ScrollBar1.Value
    tbc2Label5.Top = 150 - ScrollBar1.Value
    tbc2Label6.Top = 162 - ScrollBar1.Value
    tbc2Label7.Top = 194 - ScrollBar1.Value
    tbc2Label8.Top = 226 - ScrollBar1.Value
    tbc2Label9.Top = 278 - ScrollBar1.Value
    tbc2LabelA.Top = 130 - ScrollBar1.Value
    tbc2LabelB.Top = 265 - ScrollBar1.Value
    tbc2LabelC.Top = 317 - ScrollBar1.Value

    tbc2textbox2.Top = 39 - ScrollBar1.Value
    tbc2textbox3.Top = 71 - ScrollBar1.Value
    tbc2textbox4.Top = 105 - ScrollBar1.Value
    tbc2textbox5.Top = 174 - ScrollBar1.Value
    tbc2textbox6.Top = 206 - ScrollBar1.Value
    tbc2textbox7.Top = 238 - ScrollBar1.Value
    tbc2textbox8.Top = 290 - ScrollBar1.Value

    End Sub

    i get the message: object reference not set to an instance

    it doesn´t happen only with this event....the same happens with the next event i try to add!

    'Textbox "tbc2textbox2"
    ' Create
    tbc2textbox2.Color = cGray
    tbc2textbox2.FontColor = CBlue
    ' Add TextBox on tabControl
    ' Events AddEvent("tbc2textbox2",LostFocus,"tbc2textbox2LostFocus")

    Sub tbc2textbox2LostFocus
    tbc2LabelA.Text = tbv2textbox2.Text + tbv2textbox3.Text +tbv2textbox4.text
    End Sub

    I hope someone can help me!


  2. Erel

    Erel Administrator Staff Member Licensed User

    It looks like you got an extra space in the sub name.
  3. monster9999

    monster9999 Member


    thank´s for your answer. I suppose, that i unfortunately made this "extra space".

    in real there is no space in the sub


    it would be a help, when you could tell me, what the error message "object reference not set to an instance" means


  4. monster9999

    monster9999 Member

    i recognize that there still is this extra space posted in my second message... i don´t know why!

    so the name of the sub is correct without this space!

    AddEvent("Scrollbar1",ValueChanged,"ScrollBar1EventValueChanged") (without space)
  5. Cableguy

    Cableguy Expert Licensed User

    As far as I'm aware, it is NOT possible to add a control, to another control (panels excluded)...
    So instead of adding the scrool bar to the tabcontrol, why not add it to the form and make it visible when needed, bringing it to front as well?
  6. willisgt

    willisgt Active Member Licensed User

    Monster, what's the objective here? It looks as though you're trying to scroll through a set of controls; can you give us a little more insight as what you're actually trying to accomplish?

  7. Erel

    Erel Administrator Staff Member Licensed User

    Please upload your source code (or part of it) as a file.
  8. monster9999

    monster9999 Member


    thank´s for your answeres and tries to help me. Here you have the part of the code, which doesn´t work... i hope it will be better to understand

    Attached Files:

  9. Erel

    Erel Administrator Staff Member Licensed User

    The Sub beginning and end do not match (nested subs are not supported) :
    Sub Globals
    'Declare the global variables here.

    End Sub

    Sub App_Start
    'TabControl - für Knopf "Tool-Bilanzanalyse"
    'Bilanzanalyse - AKTIVA

    ' Label "ALabel1"  // "A Anlagevermögen"
            ' Initialisierung
                AddLabel("form1","tbc2Label1",0,0,150,15,"A Anlagevermögen")
                tbc2Label1.Color = cGray
                tbc2Label1.FontColor = cYellow
    ' Platzierung auf TabControl
    'ScrollBar1 auf AKTIVA
            ' Initialisierung
                ScrollBar1.Maximum = 
                ScrollBar1.Minimum = 
    'Plazierung auf TabControl
    Sub SBE_ValueChanged
           [/B] tbc2Label1.Top = 
    15 - ScrollBar1.Value[B]
    End Sub    

    End Sub[/B]
  10. monster9999

    monster9999 Member

    that was the misstake!
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice