Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi there.

 

I had 3 questions to ask.

 

1)

 

Public Event ButtonClicked(MessageBoxNumber As Integer, OKButton As Boolean, CancelButton As Boolean, ExitButton As Boolean)

 

--> how to code this in c#? If not mistaken, if they used the keyword WithEvent i will use delegates and events. But now is the keyword event! Any sample codes base on top?

 

2)

 

Public Property Let MessageBoxPrompt(MessageBoxNumber As Integer, ByVal vData As String)

MBox(MessageBoxNumber).Prompt = vData

End Property

 

MBox is a type of MessageBox

 

--> oh okay, i know c# got get and set, but there is no let. And can i assign property with arguments like MessageBoxNumber as integer, etc...

 

3) in vb6, you had in operator '\' for division integer, how can i achieve this in c#?

 

Any help, please?

 

Thanks.

 

Regards,

Chua Wen Ching :p

  • *Experts*
Posted

For 1, do you want to know how to declare the event, raise the event, hook the event, or all three?

 

For 3, all division by integers is, by default, rounded down (just like \). If you do division by anything other than integers, you convert the result to an Int (System.Convert.ToInt32() for example), which will round down automatically (I believe). What kind of math are you trying and what are you getting vs. what you expect?

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Posted

i expect integers...

 

yeah for the 1st one, how to do all those three...

 

for number 2, is it possible to show me some codes...

 

i try to code it...

 

but got problem..

 

once i do this...

 

the types explained above of MessageBox, i declare as Struct

 

MessageBox == SmallWindow.. something like that

 

Code

====

private struct SmallWindowType

{

public string Prompt;

public string Title;

public float X1;

public float Y1;

public float BoxWidth;

public float BoxHeight;

public float BorderColor;

public float BoxColor;

public float TextColor;

public float TitleColor;

public bool OKButton;

public bool CancelButton;

public float ButtonColor;

public float ButtonBorderColor;

public float ButtonTextColor;

public bool Clicked;

public bool Grabbed;

public float TmpX;

public float TmpY;

}

 

....

 

private SmallWindowType[] SM = new SmallWindowType[10];

 

public string SmallWindowPrompt(int SmallWindowNumber, string vData)

{

get

{

return this.SM[smallWindowNumber];

}

set

{

SM[smallWindowNumber] = vData;

}

}

 

 

When i tried to code the set thing, there is compilation errors.. it expects a semicolon behind get and set. I think my method declaration got problems.

 

Until now i seen property, they normall:

 

private Font Haha

{

get{}

set{}

}

 

and NOT

 

private string haha(int a, int b)

{

get {}

set {}

}

 

Any help?

 

For the third one, do you mean i use back '/' but convert the results into integer?

 

Thanks.

 

Regards,

Chua Wen Ching :p

Posted

So where will i place this:

 

ByVal vData As String ?

 

should it be in

 

public string SmallWindowPrompt(int SmallWindowNumber, string vData) -> ???

 

Thanks.

 

Regards,

Chua Wen Ching :p

Posted

Hmm.. ok...

 

but isn't missing of string vData, does it not affect my outcome of my project...

 

hmm.. maybe i am not good in property...

 

mind you tell me, why i should i ignore it!

 

Thanks.. thanks a lot.

 

Regards,

Chua Wen Ching :p

  • *Experts*
Posted

Have you read the help for the events? You have to declare an event interface (what the function, or the handler of the event, will look like) first, then raise the event in code. To hook an event, you need to add an event handler. If you've ever added an event to a control (like a Button's Click event), you can see the syntax by looking at the automatically generated code (look for "+=" in code).

 

I'd read up on events, delegates and such before you worry about coding events.

 

-Nerseus

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...