|
Dear all,
I am converting a VB 6.0 module into c# that is a kinda console application, i am not familier with VB syntax please help me out here...
what in the vb equivalent in c# of following
like MODULE-->
CShort(VB.Command()-->
and if there are sevral module then do i need to have write classes for each module ...
please help me here..
Thanks in advance...
T@SU
|
|
|
|
|
|
But this is not vb.net code .. this is pure VB code so can you help me here ...
Thanks In advance...
T@SU
|
|
|
|
|
Try converting it to VB.NET and then to C#
|
|
|
|
|
is there anyother way to do... coz its time taking .....
what i am looking... i have all the logic coz i have code... just i have to reachitecture according to c# ... so what help i am looking for..
just in c# we are having a namespace then a class inside member variable and function... so how it is done in VB ...
please help me...
Thanks alot ....
T@SU
|
|
|
|
|
Hi,
May be this will help you
Look here/[^]
Regards,
Keep Smiling
|
|
|
|
|
I THINK THAT IS SOME PAID THING...
I have some very basic doubts... like what si it ment by module ...
how can i create a class as for C#...
if u have have couple of modules... then how can u relates all those in c#....
thanks... for help...
T@SU
|
|
|
|
|
Here is what I have so far:
using System;
namespace ZipArray
{
class Program
{
public class ZipSort
{
string[] zipCodes = new string[10]
{
"33701",
"33702",
"33703",
"33704",
"33705",
"33706",
"33707",
"33708",
"33709",
"33710"};
int x;
Console.Write("Please enter a zip-code : ");
string zipSearch = Console.ReadLine();
bool found = false;
foreach(string zip in zipCodes)
{
if (zip == zipSearch)
{
found = true;
break;
}
}
Console.WriteLine();
if (found)
{
Console.WriteLine("The zip-code, {0}, is delivered to", zipSearch);
}
else
{
Console.WriteLine("The zip-code, {0}, is not delivered to", zipSearch);
Console.WriteLine();
Console.WriteLine("The full list is :");
Console.WriteLine();
Array.Reverse(zipCodes);
for(x=0; x<zipcodes.length;++x)>
Console.WriteLine(zipCodes[x]);
}
} I have been unable to make this program run correctly thus far, I am trying to make it to where it will allow the user to enter a zip code and if it is on the list it will read "the zip code "0" is delivered to" and after that to sort the zip codes in descending order. Any help would be much appreciated!
|
|
|
|
|
where is the Problem?
In the input or show section (the input/find looks fine but the for-loop won't compile (it's not even closed))?
|
|
|
|
|
using System;<br />
using System.Collections.Generic;<br />
using System.Text;<br />
<br />
namespace ConsoleApplication1<br />
{<br />
class Program<br />
{<br />
static void Main(string[] args) {<br />
<br />
string[] zipCodes = new string[10]{"33701","33702","33703","33704","33705",<br />
"33706","33707","33708","33709","33710"};<br />
<br />
Console.Write("Please enter a zip-code : ");<br />
string zipSearch = Console.ReadLine();<br />
bool found = false;<br />
<br />
foreach (string zip in zipCodes) {<br />
if (zip == zipSearch) {<br />
found = true;<br />
break;<br />
}<br />
}<br />
Console.WriteLine();<br />
<br />
if (found) {<br />
Console.WriteLine("The zip-code, {0}, is delivered to", zipSearch);<br />
} else {<br />
Console.WriteLine("The zip-code, {0}, is not delivered to", zipSearch);<br />
Console.WriteLine();<br />
Console.WriteLine("The full list is :");<br />
Console.WriteLine();<br />
}<br />
<br />
Array.Reverse(zipCodes);<br />
for (int i = 0; i < zipCodes.Length; i++) {<br />
Console.WriteLine(zipCodes[i]);<br />
}<br />
Console.WriteLine("Press a key to Continue.");<br />
Console.ReadLine();<br />
}<br />
}<br />
}<br />
|
|
|
|
|
Thanks alot F16I ! I think I see what I was doing wrong now. Much obliged !
|
|
|
|
|
Hi all,
I am new to Window services.
How can i make a http request through a windows service.
For a particular amount of time the request must be invoked .
Please reply to me.
Thanks and regards
Narendra Mohan.S
|
|
|
|
|
Just like you would do it in a winforms-app - you just have to watch out not to run into CAS issues (normaly a windows-service runs in a local-service account with fewer rights - if you've got some Security-exceptions try running the service as administrator (for debug-purposes!)
|
|
|
|
|
Hi,
I'm writing a simple control that will "grow down" vertically as the user types.
In this case 'word-wrap' must be on, and I want to detect a word-wrap event and resize the control appropriately.
I can't find any top-level control event triggred by a word-wrap. Yes, I have looked through the CodeProject archives, already, for some similar example.
Appreciate any clues. Perhaps a wndProc is required ?
Will look forward to posting working example to CodeProject.
thanks ! Bill
"The greater the social and cultural distances between people, the more magical the light that can spring from their contact." Milan Kundera in Testaments Trahis
|
|
|
|
|
I can't find anything helpfull either.
All i can suggest is selecting a monotype font, so that you know the width of everyt character, and then work out the height of the text yourself, comparing this to the hieght of the control. And then adjusting as necessary.
So, if every character was 6px wide and 8px high, and the text box was say, 300px wide:
string[] text = richTextBox.Lines;
int height = 0;
foreach(string line in text) {
int width = line.Length*6;
height += 300/width;
}
this.richTextBox.Height = height*8;
I think that would work out.
EDIT:Alternitavly, you can inherit from the control, and look into the paint event to see what the drawing does, but that might be a little more complicated.
Alternitavly again, which may be a better solution, would be to inhertin the control, and do the drawing yourself, that way you would know exactly how much space the text takes up. You could make an article of it. Infact, if you don't, i will. (So, that would be 3 articles i must get around to doing )
EDIT: fixed a slight mathamatical error
My current favourite word is: Bauble!
-SK Genius
modified on Sunday, December 16, 2007 1:02:24 PM
|
|
|
|
|
Thanks for your input -SKGenius !
I'm certainly not going to "get down" with the 'Paint even any time, so I do hope you'll do an article on that approach, but I suspect that there is an API somewhere that can be used in a wndproc or something to get a word-wrap event.
best, Bill
"Education consists mainly in what we have unlearned." Mark Twain
"The greater the social and cultural distances between people, the more magical the light that can spring from their contact." Milan Kundera in Testaments Trahis
|
|
|
|
|
Well unfortunately this wouldn't work, each character has a different width with true type fonts.
There is such a thing called kerning in which you could compute it, I am looking for the formula myself.
|
|
|
|
|
I'm after a bit of guidance, here's my story...
For learning purposes I have built a very simple Web Service which returns a List<model></model> , which is a list of models (or model kits - Spitfires, Hurricanes, Mustangs, Naval Ships and etc).
It's very basic, but it works which is good.
I also have a client application I built in VS 2008 - I used the Wizard, and WCF went ahead and did its magic - which is also good, and works.
However, I'd like to enable the column header clicking and sorting in the dataGrdidView against this bound List, which currently is not working. Ideally I want all sorting and whatnot to happen on the client in order to prevent repeated round trips to the web service.
I have a work around which involves using a healthy dose of reflection against the List in order to build a DataTable, which has built in support for sorting and ordering, however I'm not entirely convinced that this is the "right" solution given:
a) I came up with it, so it's bound to be wrong
b) Reflection has a performance overhead (well, not my machine, which is a power house of brute computational force... but you see my point)
c) I'm sure there's a simpler solution which I don't know about
So the question is, how can I enable sorting and ordering against this List without relying on my "workaround". I've had a look in the generated Model class, and it has all manner of dire warnings about changes being lost and so on, so I guess that rules changing that out... any thought?
"On one of my cards it said I had to find temperatures lower than -8. The numbers I uncovered were -6 and -7 so I thought I had won, and so did the woman in the shop. But when she scanned the card the machine said I hadn't.
"I phoned Camelot and they fobbed me off with some story that -6 is higher - not lower - than -8 but I'm not having it."
-Tina Farrell, a 23 year old thicky from Levenshulme, Manchester.
|
|
|
|
|
Ah ha, IComparer to the rescue... almost. It seems that I need to do some abstracting/refactoring and reflection may still come in to play as it doesn't appear that I can send a sort direction into an IComparer, unless anyone knows differently?
"On one of my cards it said I had to find temperatures lower than -8. The numbers I uncovered were -6 and -7 so I thought I had won, and so did the woman in the shop. But when she scanned the card the machine said I hadn't.
"I phoned Camelot and they fobbed me off with some story that -6 is higher - not lower - than -8 but I'm not having it."
-Tina Farrell, a 23 year old thicky from Levenshulme, Manchester.
|
|
|
|
|
Rapidly coming to the conclusion that using reflection and converting to a DataTable is the best option afterall...
"On one of my cards it said I had to find temperatures lower than -8. The numbers I uncovered were -6 and -7 so I thought I had won, and so did the woman in the shop. But when she scanned the card the machine said I hadn't.
"I phoned Camelot and they fobbed me off with some story that -6 is higher - not lower - than -8 but I'm not having it."
-Tina Farrell, a 23 year old thicky from Levenshulme, Manchester.
|
|
|
|
|
Seeing that you have this project in 2008, why not just use LINQ? That way you can sort the same list ascending/descending to your hearts content. As you have a list, you can easily use LINQ for objects on this.
|
|
|
|
|
Whilst LINQ is very cool (I'm using LINQ to SQL in the web service to save on hand coding a DAL), I don't understand enough about how it works yet to get what I want to work to... er... work.
Perhaps I'll try all 3 approaches and write an article.
"On one of my cards it said I had to find temperatures lower than -8. The numbers I uncovered were -6 and -7 so I thought I had won, and so did the woman in the shop. But when she scanned the card the machine said I hadn't.
"I phoned Camelot and they fobbed me off with some story that -6 is higher - not lower - than -8 but I'm not having it."
-Tina Farrell, a 23 year old thicky from Levenshulme, Manchester.
|
|
|
|
|
Well, suppose you have a list called _myList you could use:
var list = _myList.OrderBy(i=>i.ItemName); and to do it descending you could use:
var list = _myList.OrderByDescending(i=>i.ItemName);
|
|
|
|
|
Ok, so that's cool... but suppose I throw into the mix that I want the property name to be specified by which column was clicked... as in, there's a column called "Model_Name" which maps to model.Model_Name, how do I specify i."Model_Name" ?
"On one of my cards it said I had to find temperatures lower than -8. The numbers I uncovered were -6 and -7 so I thought I had won, and so did the woman in the shop. But when she scanned the card the machine said I hadn't.
"I phoned Camelot and they fobbed me off with some story that -6 is higher - not lower - than -8 but I'm not having it."
-Tina Farrell, a 23 year old thicky from Levenshulme, Manchester.
|
|
|
|
|
To do this, you need to build your own expression tree. Here's one I prepared earlier:
ParameterExpression ep = Expression.Parameter(typeof(Customer), "p");
MemberExpression me = Expression.PropertyOrField(ep, "CompanyName");
LambdaExpression le = Expression.Lambda(me, "CompanyName");
Type[] argTypes = { c.ElementType, le.Body.Type };
MethodCallExpression mce = Expression.Call(typeof(Queryable), "OrderBy", argTypes, c.Expression, le);
IQueryable queried = c.Provider.CreateQuery(mce);
|
|
|
|
|