Owner Info help needed

Discussion in 'Questions (Windows Mobile)' started by kshetarpal, Nov 17, 2007.

  1. kshetarpal

    kshetarpal Member Licensed User

    I am a new user of Basic4PPC. I tried the following code to get ownerinfo based on a code sample. Upon compiling I get nothing. Obviously, I am doing something wrong here.
    Here is the code:

    Sub Globals
    Dim buff(0) As Byte
    End Sub

    Sub App_Start
    Reg.New1 'Registry object is named 'reg'
    End Sub

    Sub Button1_Click
    If CPPC = false Then Return 'this is not for the desktop
    Dim m
    buff() =Reg.GetValue("ControlPanel\Owner\","Owner")
    For i = 0 To ArrayLen(buff()) -1 Step 2
    If buff(i)=0 Then Exit 'Chr(0) separates the name from other owner entries
    m = m & Chr(buff(i))
    Return m
    Msgbox ("Owner name ",m)
    TextBox1.Text= m
    End Sub

    Sub Button2_Click
    End Sub

    I would appreciate the corrections of the code.

    Amit Kshetarpal
  2. colin9876

    colin9876 Active Member Licensed User

    hi, I might be wrong....
    1)But can u just Dim m like that? dont u have to do it in the Globals area and define how many elements the array has in it?
    2) you've Dim-ed Buff as (0) bytes long - THATS NO LENGTH? wont u need it long enough to store the name?? {Or does Dim buff(0) mean it can be any length?}

    (if Im wrong on the above points please correct me, cos Im a newbie?)
    Last edited: Nov 17, 2007
  3. Erel

    Erel Administrator Staff Member Licensed User

    Remove 'Return m' if you want the msgbox to appear, and the TextBox be assigned.
    Return leaves the sub immediately.
    1) Dim m is equivalent to m = "".
    It is absolutely legal to use it. The result will be a local variable.
    If it were declared under Sub Globals then it would have been a global variable.
    See this topic for more information: http://www.basic4ppc.com/help/variables.html
    2) You can declare an empty array.
    Later you will need to redimension it with another dim or (in this case) call a function that returns an array.
    buff() =Reg.GetValue("ControlPanel\Owner\","Owner")
    Reg.GetValue returns an array of bytes.
    Using ArrayLen you can find the size of the array returned.
  4. kshetarpal

    kshetarpal Member Licensed User

    Thanks, the solution worked by removing the Return statement.
  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