Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Questions (Windows Mobile)
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Questions (Windows Mobile) Post any question regarding Basic4ppc.

a question for agraham

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-18-2008, 11:19 AM
Basic4ppc Veteran
 
Join Date: Sep 2008
Location: Brisbane, Australia
Posts: 317
Default a question for agraham

Gday mate.

I'm converting the vb version of autocomplete into C# using VS2005.

this line in VB
If item.ToUpper.StartsWith(strg) Then

the StartsWith doesn't seem to be in C#

here is the VB code block
If item.ToUpper.StartsWith(strg) Then
found = True
Exit For
End If

how should I write this in C#?

regards, Ricky
Reply With Quote
  #2 (permalink)  
Old 10-18-2008, 03:53 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by Ricky D View Post
StartsWith doesn't seem to be in C#
It is, it is a method of the String class and so is language independent.

Code:
if (item.ToUpper.StartsWith(strg))
{
    dosomething();
}
else
{
   dosomethingelse();
}
Reply With Quote
  #3 (permalink)  
Old 10-19-2008, 10:27 AM
Basic4ppc Veteran
 
Join Date: Sep 2008
Location: Brisbane, Australia
Posts: 317
Default thanks, another one

what's the equivalent of Exit For ?

regards, Ricky
Reply With Quote
  #4 (permalink)  
Old 10-19-2008, 10:37 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by Ricky D View Post
what's the equivalent of Exit For ?
Break;
Reply With Quote
  #5 (permalink)  
Old 10-19-2008, 10:43 AM
Basic4ppc Veteran
 
Join Date: Sep 2008
Location: Brisbane, Australia
Posts: 317
Default thanks

thanks again. Now to test tomorrow. Sleep time now!

regards, Ricky
Reply With Quote
  #6 (permalink)  
Old 10-19-2008, 11:57 AM
Basic4ppc Veteran
 
Join Date: Sep 2008
Location: Brisbane, Australia
Posts: 317
Default Another one - keyup event not working

Hi again agraham.

this is the keyup code for the internal textbox :

private void txtText_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
{
string strg = txtText.Text.ToUpper();
string cboitem="";
bool found = false;
int jj=0;

System.Windows.Forms.MessageBox.Show("hey");
if (e.KeyData == Keys.Back)
{
e.Handled = true;
return;
}

if (mAutoCompleteOn == false)
{
e.Handled = true;
return;
}

for (int j = 0; j < cboCombo.Items.Count; j++)
{
cboitem = (string)cboCombo.Items[j];
if (cboitem.ToUpper().StartsWith(strg))
{
jj = j;
found = true;
break;
}
}

if (found)
{
txtText.Text = cboitem;
txtText.SelectionStart = strg.Length;
txtText.SelectionLength = txtText.Text.Length - strg.Length;
cboCombo.SelectedIndex = jj;
}
}

can you see why this isn't being fired when I type in the text portion of the control? I put the messagebox there for debugging.

regards, Ricky
Reply With Quote
  #7 (permalink)  
Old 10-19-2008, 12:09 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 6,072
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Probably because you haven't added the event delegate to the textbox event in your constructor.

Code:
TextBox yourtextbox; // private variable
  ...
yourtextbox = new TextBox (); // in the constructor 
yourtextbox.KeyUp += txtText_KeyUp; // add a delegate 
to the event
  ...
Reply With Quote
  #8 (permalink)  
Old 10-19-2008, 12:21 PM
Basic4ppc Veteran
 
Join Date: Sep 2008
Location: Brisbane, Australia
Posts: 317
Default that was it

again many thanks. It's harder than vb so what's the attraction to C#? Is it just that you have done C before?

In my formative years I started on Z80 processors doing assembly and turbo pascal. When Dos came along then windows I'd see code written in C that was so unreadable that it turned me off it way back then. No one would be kind enough to explain it in a simple way. Hence I like the "verbose" languages that came along like pascal and basic. I found cobol way too verbose and disliked it for being on the other end of the verbosity scale where c was least to cobol largest lol

I taught myself how to program and have seen clipper on pc, pascal on pc, Rally on Vax/VMS plus Cobol on same. In college I did a bit of Fortran too.

My how the landscape of IT has changed.

regards, Ricky
Reply With Quote
  #9 (permalink)  
Old 10-19-2008, 12:30 PM
Erel's Avatar
Administrator
 
Join Date: Apr 2007
Posts: 15,726
Awards Showcase
Basic4ppc Founder 
Total Awards: 1
Default

VB .Net and C# are almost identical. There are even many automatic code converters between the two.
For example: Convert VB.NET to C# - A free code conversion tool - developerFusion - the global developer community
Personally I prefer C# because of its "cleaner" syntax.
Reply With Quote
  #10 (permalink)  
Old 10-19-2008, 12:36 PM
Basic4ppc Veteran
 
Join Date: Sep 2008
Location: Brisbane, Australia
Posts: 317
Default hi Erel

do you program B4ppc in C# for the desktop and device?

I can't get this autocomplete working in C# and can't see how to debug what's going on inside the dll

it's working in vb so I'll leave it at that I think.

Here is the code that's not working

if (found)
{
txtText.Text = cboitem;
txtText.SelectionStart = strg.Length;
txtText.SelectionLength = txtText.TextLength - strg.Length;
cboCombo.SelectedIndex = jj;
}

what it does is when I type W for World it brings back the World string and places the caret at the start of the text instead of at the end. It also doesn't select the orld part of the text.

regards, Ricky

Last edited by Ricky D : 10-19-2008 at 12:44 PM.
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 Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
a question for erel or agraham or anyone else Ricky D Questions (Windows Mobile) 14 10-29-2008 06:43 PM
Merging agraham libraries with the exe agraham Additional Libraries 10 05-28-2008 04:40 PM
Two new awards were given to agraham and dzt Erel Forum Discussion 14 01-27-2008 01:08 AM
I vote for agraham! dzt Chit Chat 7 10-26-2007 06:47 PM


All times are GMT. The time now is 02:50 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0