Basic4ppc - Windows Mobile Development  

Go Back   Basic4ppc - Windows Mobile Development > Main Category > Questions & Help Needed
Home Register FAQ Members List Search Today's Posts Mark Forums Read

Questions & Help Needed Post any question regarding Basic4ppc.


Owner Info help needed


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-17-2007, 06:04 PM
Junior Member
 
Join Date: Nov 2007
Posts: 17
Default Owner Info help needed

Hi,
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'
Form1.Show
End Sub


Sub Button1_Click
If CPPC = false Then Return 'this is not for the desktop
Dim m
Reg.RootKey(Reg.rtCurrentUser)
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))
Next
Return m
Msgbox ("Owner name ",m)
TextBox1.Text= m
End Sub

Sub Button2_Click
AppClose
End Sub

I would appreciate the corrections of the code.

Amit Kshetarpal
Reply With Quote
  #2 (permalink)  
Old 11-17-2007, 06:33 PM
Basic4ppc Veteran
 
Join Date: Nov 2007
Posts: 316
Awards Showcase
Beta Tester 
Total Awards: 1
Default

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?
also
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 by colin9876 : 11-17-2007 at 06:41 PM.
Reply With Quote
  #3 (permalink)  
Old 11-17-2007, 06:58 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 3,334
Default

Remove 'Return m' if you want the msgbox to appear, and the TextBox be assigned.
Return leaves the sub immediately.
Quote:
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?
also
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?}
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.
Code:
buff() =Reg.GetValue("ControlPanel\Owner\","Owner")
Reg.GetValue returns an array of bytes.
Using ArrayLen you can find the size of the array returned.
Reply With Quote
  #4 (permalink)  
Old 11-18-2007, 05:36 AM
Junior Member
 
Join Date: Nov 2007
Posts: 17
Default

Thanks, the solution worked by removing the Return statement.
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing info from Windows WM6.1 DLL aerohost Questions & Help Needed 3 08-18-2008 06:14 PM
How to obatin screen size and o/s info? alfcen Questions & Help Needed 8 04-13-2008 04:25 AM
Would like some more info Mr_Gee Questions & Help Needed 5 02-26-2008 06:01 AM
XML-support needed Frank Questions & Help Needed 2 01-29-2008 07:56 PM
Detab in IDE and Error info agraham Basic4ppc Wishlist 3 11-11-2007 11:34 AM


All times are GMT. The time now is 01:23 PM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.1.0