Mike Askew 131 Veteran Poster Featured Poster

As mentioned above you need a Main method.

The syntax above is not C# however and I think somebody got lost from his C++ forum :D

The default C# main method is the following:

static void Main(string[] args)
{
    // Code goes here
}

This is occuring in your case as it looks like you are trying to create classes for a ClassLib however the project will be console based and therefore you still need a Main program class in order for it to build. The other option is to make a Class Library project which does not require the Main method to build.

You can make a new class that looks like the following:

namespace Lesson02
{
    class MainProgramClass 
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Running");
            Console.ReadLine();
        }
    }
}

and it should compile then.

Mike Askew 131 Veteran Poster Featured Poster

Yeah I have access to TFS online through my MSDN Subscriber benefits so could also use that.

Did debate asking Dani if there was any place such things could be hosted internally to the site as its obviously related and then just writing up a tutorial. Would keep the code more private though.

Mike Askew 131 Veteran Poster Featured Poster

Yeah had a look at GitHub the other day but couldn't figure out how to work it :D

I think I was being stupid.

Mike Askew 131 Veteran Poster Featured Poster

So been working on a C# wrapper for the DW API for a while now and its moving into the closing stages of development and I will release it publicly after.

Question I have is what would be the best way to do this and how?

(I am still waiting for Dani to release the JSON for the OAuth requiring calls though to map them :D)

Mike Askew 131 Veteran Poster Featured Poster

If the answer is No to the first question, the next four become difficult to answer without providing false data.

Mike Askew 131 Veteran Poster Featured Poster

You would most likely use logic along the following lines.

  1. Have a public facing property on the pop-up form.
  2. When a row is chosen on the pop-up form, set the property to the details of the row (briefly discussed below).
  3. Back in the main form, during the if check for the ok response from the pop-up, if it is true, you retrieve the values onto the main form through the exposed property.

If you wanted all the values from the selected row I guess you would need to put them into a string and .Split() it the other end, or use an array/list to store the multiple values.

In terms of how to do it using a list view, you could make use of the SelectedIndexChanged event to update the property.

Else please elaborate further if I have not understood :)

Mike Askew 131 Veteran Poster Featured Poster

What have you got so far in terms of code?

Mike Askew 131 Veteran Poster Featured Poster

I guess so yes, consistency would be the best option.

Mike Askew 131 Veteran Poster Featured Poster

Thanks :), it doesn't have to fake it though, just didn't know if that was correct or not.

I can code to handle there being no related articles.

That's your choice what to do though :)

Mike Askew 131 Veteran Poster Featured Poster

Ooo driving tanks does sound rather fun :D

Mike Askew 131 Veteran Poster Featured Poster

Then we share the same birthday AD, 22 today :)

Mike Askew 131 Veteran Poster Featured Poster

What don't you understand about it?

Mike Askew 131 Veteran Poster Featured Poster

Yeap, KeyDown or KeyPress as I covered above would work. IIRC KeyDown has a different event parameter which would variate it slightly from my example?

Mike Askew 131 Veteran Poster Featured Poster

This also occurs when querying the community feedback forum with the current 28th post in the list having an identical issue.

PostID: "469250"

Mike Askew 131 Veteran Poster Featured Poster

@ddanbe, OP was after the text move triggering by the <enter> key press :)

Mike Askew 131 Veteran Poster Featured Poster

The enter event only fires when you give the control focus when it previously didn't have it. For example clicking on the textbox.

You would need to fire the code under a KeyPress event for textbox1 and use

if (e.KeyChar == (char)13)
{
    listbox1.items.add(textbox1.text);
}

to detect it was the enter key pressed and add the text to the list.

Mike Askew 131 Veteran Poster Featured Poster

Have you tried a this.Update(); after the call to SearchEndDate();? This will force the form to redraw.

Mike Askew 131 Veteran Poster Featured Poster

Been running a couple of article queries this morning.

When running http://www.daniweb.com/api/articles?forum_id=61 I encountered what looks like a bug.

The 11th thread reply coming back in the query is the following:

{
   "title":"please help me  .........",
   "related":[
    {
     "id":""
    }
   ],
   "posters":[
    {
     "id":"1098860"
    },
    {
     "id":"46588"
    },
    {
     "id":"1091071"
    }
   ],
   "uri":"http:\/\/www.daniweb.com\/software-development\/csharp\/threads\/472052\/please-help-me-",
   "id":"472052",
   "forum":{
    "id":"61"
   },
   "replies_count":"2",
   "views_count":"20",
   "first_post":{
    "timestamp":"1390849755",
    "id":"2060455",
    "poster":{
     "username":"0914541592",
     "id":"1098860"
    },
    "raw_message":"2.\tAn integer greater than 1 is said to be prime if it is divisible by only 1 and itself. For example, 2, 3, 5 and 7 are prime numbers, but 4, 6, 8 and 9 are not.\na) Write a function that determines whether a number is prime.\nb) Use this function in a program that determines and prints all the prime numbers between 2 and 1,000.\nc) Initially, you might think that n\/2 is the upper limit for which you must test to see whether a number is prime, but you need go only as high as the square root of n. Rewrite the program and run it both ways to show that you get the same result.\n"
   },
   "type":"threads",
   "last_post":{
    "timestamp":"1391014107",
    "id":"2061046",
    "poster":{
     "username":"humorousone"
    }
   }
  },

Note how in the related threads section, it shows a thread is returned however no ID for this thread is actually given (Line 5).

When looking at the actual forum thread (http://www.daniweb.com/software-development/csharp/threads/472052/please-help-me-) there are 10 related articles shown on the side.

Also if I run http://www.daniweb.com/api/articles/472303 which is the direct query …

Mike Askew 131 Veteran Poster Featured Poster

The duplicate did exist Ket, as it was I who flagged it.

Mike Askew 131 Veteran Poster Featured Poster

The code is correct assuming those are the names of the objects. As KM499 said, please provide the full code as there may be other interfering factors.

Mike Askew 131 Veteran Poster Featured Poster

Whats the database structure like?

Mike Askew 131 Veteran Poster Featured Poster

What have you got so far?

I will happily help you with errors when stuck but I don't get paid to write the code for you, neither does anyone else on this site.

Mike Askew 131 Veteran Poster Featured Poster

I personally couldn't comment on how to do it without the SDK as it isn't something I have done.

But even if you manage to access this device without using the SDK, another device may have a different underlying setup which again would break your code. Making your whole choice of access pointless and may as well have just used the SDK.

Either way expect to have to write multiple ways depending upon which device is used, SDK would be simpler.

Mike Askew 131 Veteran Poster Featured Poster

I am not using the sdk provided by the vendor

There is your first issue. You will need to use it and write seperate classes depending on which scanner is plugged in. You would be better off developing for one specific type though as even by avoiding using the SDK if you manage to access the scanner's memory that may not work on a different type.

Mike Askew 131 Veteran Poster Featured Poster

Never noticed the education bit actually, good spot.

Either way the value is still not right

Mike Askew 131 Veteran Poster Featured Poster

Either / Or.. something doesn't line up :D

Mike Askew 131 Veteran Poster Featured Poster

Running Dani's profile as an example I get the JSON back containing:

"education":[
 {
  "key":"education",
  "value":"B.S. Computer Science",
  "organization":"Hofstra University",
  "start":"September 2000",
  "end":"December 2005",
  "description":"I majored in Computer Science and minored in Business Computer Information Systems. I was in Upsilon Pi Epsilon, the Computer Science Honor Society run by the ACM and IEEE. I TA'ed multiple Computer Science courses and also worked as a private tutor. I almost double-minored in chemistry and subsequently won an award from the American Chemical Society. I founded DaniWeb my sophomore year of college after getting frustrated that I was one of the few department tutors and there was no where available for me to get help myself. Upon its success, I finished my last year and a half of school taking part-time night courses and focusing on DaniWeb fulltime, ultimately completing my 4-year degree in 5.5 years with a business to go into upon graduation.",
  "id":"3"
 },

Should it not be:

"education":[
 {
  "DEGREE":"education",
  "SCHOOL":"B.S. Computer Science",
  "organization":"Hofstra University",
  "start":"September 2000",
  "end":"December 2005",
  "description":"I majored in Computer Science and minored in Business Computer Information Systems. I was in Upsilon Pi Epsilon, the Computer Science Honor Society run by the ACM and IEEE. I TA'ed multiple Computer Science courses and also worked as a private tutor. I almost double-minored in chemistry and subsequently won an award from the American Chemical Society. I founded DaniWeb my sophomore year of college after getting frustrated that I was one of the few department tutors and there was …
Mike Askew 131 Veteran Poster Featured Poster

As this was ressed.. some of us on the forum know a bit of both languages and can help you if needed.

I will normally look at conversion topics when posted in C#, always fun to keep my VB.Net slightly active.

Mike Askew 131 Veteran Poster Featured Poster

As Ketsuekiame said, you already open the connection on line 39 and don't shut it then, hence the exception you see being thrown.

A good practice here is to use [code lifted off net, hence using different connection, easy to change to yours]

    using (SqlConnection connection = new SqlConnection(connectionString))  
    {  
        SqlCommand command = connection.CreateCommand();  

        command.CommandText = "mysp_GetValue";  
        command.CommandType = CommandType.StoredProcedure;  

        connection.Open();  
        object ret = command.ExecuteScalar();  
    }  

when you are going to databases, this will mean you don't have to worry about closing the connection as it will be done for you when the end of the using is reached.

Mike Askew 131 Veteran Poster Featured Poster

What error do you get and on which line does it occur?

It is difficult to help when you provide us with minimal information regarding the error.

Mike Askew 131 Veteran Poster Featured Poster

Forgot about this over the weekend.

You may need to play with intellisense and see what is actually available to you from the API.

Again can't offer much more help than that as don't have any knowledge of the systems you're working with myself.

Mike Askew 131 Veteran Poster Featured Poster

Also here: Stack Overflow

Watching this out of interest

Mike Askew 131 Veteran Poster Featured Poster

am not able to arrange text in proper manner in text file. can you please tell me how to do it...?

Make a new thread and we could tell you how to yes. Don't res and hi-jack a thread that is 5 years old and dead for over a year.

Mike Askew 131 Veteran Poster Featured Poster

Set your combobox Text property to the default value you want to display.
If the selected index doesn't exist in the DB, set your SelectedIndex on the combo box to -1. This will revert it to your default text.

I don't get this behaviour when testing, the box remains blank after setting the index to -1 from another value (VS2012/.Net4.5).

I disagree with the downvote though, it is a better route than manually adding an item.

Mike Askew 131 Veteran Poster Featured Poster

I have no clue about how the scanner you are working with functions. So cannot help debug issues with it.

I simply did the code convert.

What error does it give?

Mike Askew 131 Veteran Poster Featured Poster

As this is university work you should really have tried doing it with the conversion tools but I had little to do for 15 mins and was interested to see how well I could do the conversion.

It may not be 100% working if you just copy and paste in but is a start.

            //The name of the window fingerprint control is ZKFPEngX1.
            //At first, press Initialize button to initialize the fingerprint Sensor. If the
            //initialization is successful, a prompt message which indicates a success will be
            //shown.
            //The initialization code is as the following:

            if (ZKFPEngX1.InitEngine == 0)
            {
                MessageBox.Show("Initialization succeeds!", "Prompt message");
                StatusBar.Caption = "Fingerprint Sensor connection";
                TextSensorCount.Text = ZKFPEngX1.SensorCount & "";
                TextSensorIndex.Text = ZKFPEngX1.SensorIndex & "";
                TextSensorSN.Text = ZKFPEngX1.SensorSN;
                cmdInit.Enabled = False;
                FMatchType = 0;
            }

            //Press the Register Fingerprint button to enter the fingerprint registration
            //status, and the code is like the this:

            if (TextFingerName.Text.Trim() == "")
            {
                MessageBox.Show("Please enter the fingerprint name label! ", "False");
                return;
            }
            ZKFPEngX1.BeginEnroll();
            StatusBar.Caption = "Start registration";

            //At this moment, the fingerprint Sensor is under the status of registration,
            //and every time pressing a finger will trigger events OnImageReceived (display
            //images),and OnFeatureInfo(judge whether the fingerprint is qualified or not).
            //Pressing a finger for one or four effective times (not counting times if the finger is
            //unqualified) will trigger events OnEnroll and OnEnrollToFile, and the specific
            //pressing times number is set by the property EnrollCount. OnEnroll code is like
            //this :

            long i;
            if (!ActionResult)
            {
                MessageBox.Show("Fingerprint registration failed! …
Mike Askew 131 Veteran Poster Featured Poster

Functioning code for those interested.

        private void button1_Click(object sender, EventArgs e)
        {
            string FileName = @"D:\FooBar.xlsx";

            Excel.Application xlApp = new Excel.Application();
            Excel.Workbooks xlWBs = xlApp.Workbooks;
            Excel.Workbook xlWB = xlWBs.Open(FileName);

            ProcessChanges(xlWB);

            Marshal.ReleaseComObject(xlWB);
            Marshal.ReleaseComObject(xlWBs);
            Marshal.ReleaseComObject(xlApp);

            var processes = from p in Process.GetProcessesByName("EXCEL")
                            select p;

            foreach (var process in processes)
            {
                    process.Kill();
            }

            MessageBox.Show("Done");
        }

        private void ProcessChanges(Excel.Workbook workBook)
        {

            Excel.Worksheet sheet = (Excel.Worksheet)workBook.Sheets[2];

            Excel.Range excelRange = sheet.UsedRange;

            object[,] valueArray = (object[,])excelRange.Value2;

            string TextToMove = valueArray[1, 1].ToString().Substring(valueArray[1, 1].ToString().IndexOf("Prerequisites"), valueArray[1, 1].ToString().IndexOf("2."));

            excelRange.Cells.set_Item(6, 3, string.Concat(valueArray[6, 3].ToString(), "\n\n", TextToMove));

            workBook.Save();
        }
Mike Askew 131 Veteran Poster Featured Poster

I've been toying with some code for the last thirty mins to try move a substring from one cell to another. In debug I can see the correct contents being picked up and moved to the new cell and even got a save prompt popup when running over line 31.

private void button1_Click(object sender, EventArgs e)
        {
            string FileName = @"D:FooBar.xlsx";

            Excel.Application xlApp = new Excel.Application();
            Excel.Workbooks xlWBs = xlApp.Workbooks;
            Excel.Workbook xlWB = xlWBs.Open(FileName);

            ProcessChanges(xlWB);

            xlWB.Close();
            xlWB = null;
            xlWBs = null;
            xlApp.Quit();
            xlApp = null;

            MessageBox.Show("Done");
        }

        private void ProcessChanges(Excel.Workbook workBook)
        {
            Excel.Worksheet sheet = (Excel.Worksheet)workBook.Sheets[2];

            Excel.Range excelRange = sheet.UsedRange;

            object[,] valueArray = (object[,])excelRange.get_Value(Excel.XlRangeValueDataType.xlRangeValueDefault);

            string TextToMove = valueArray[1, 1].ToString().Substring(valueArray[1, 1].ToString().IndexOf("Prerequisites"), valueArray[1, 1].ToString().IndexOf("2."));
            valueArray[6, 3] = string.Concat(valueArray[6, 3].ToString(), "\n\n", TextToMove);
            workBook.Save();
        }

However the document didn't seem to save the actual changes and can't figure out why. It also locks open the file until I kill off excel via task manager so I'm clearly doing something wrong there also.

Any ideas?

Mike Askew 131 Veteran Poster Featured Poster

One is very confused.

Mike Askew 131 Veteran Poster Featured Poster

Can you show an example of what you wish to do.

Also what code have you got so far? I am not paid to write your code for you.

Mike Askew 131 Veteran Poster Featured Poster

You're welcome to post the code, I personally haven't touched VB.Net in years so may not be able too. Someone else maybe could.

Mike Askew 131 Veteran Poster Featured Poster

Would be better to start a new thread.

By a single instance do you mean like one line or in one method?

Mike Askew 131 Veteran Poster Featured Poster

Have you tried experimenting with the provided libraries?

Their site also confirms it supports C# so you may just need to get the correct libraries.

Mike Askew 131 Veteran Poster Featured Poster

Are you sure the tool is compatible with C# then?

The producer of the fingerprint tool sadly gets to decide how you connect to their products and so if the SDK exists in VB code, then that may be the only way to do so.

What is the fingerprint tool?

Mike Askew 131 Veteran Poster Featured Poster

Please provide the code you are working with

Mike Askew 131 Veteran Poster Featured Poster

Do you mean you're going to turn it on again then? :)

Nope, meant turn it off (Was currently turned on) as it wasn't what I thought it would be and hotmail has quite poor facilities in terms of rule construction (Very simplistic compared to the desktop version of outlook), would take me forever to set it up to function how I wanted.

Mike Askew 131 Veteran Poster Featured Poster

Ok so we just got the concept wrong :)

I'll turn it off again then, the idea would have been nice if implemented in the same way the current notifications worked also

Mike Askew 131 Veteran Poster Featured Poster

Did I miss something in how this works?

Assumption was that it would be like the usual notification emails but allows you to reply to the thread via the email.

Instead I seem to be getting emails allowing me to reply to new threads in the community center than I am not even watching (as email received when they are made)

If the latter is correct and not a bug, I think I will go back to the old fashion method, I prefer not to have too much flooding on my inbox :)

Mike Askew 131 Veteran Poster Featured Poster

i think you can add value of label in query string . and on page load event just check if it is post back then get the value from query string and set to label :P .

This would of course allow it to be changed by the user by editing the URL bar, causing security implications. Not sure if that would cause problems for the OP; Depends upon what information is being maintained between pages.

Otherwise a fine suggestion.

Mike Askew 131 Veteran Poster Featured Poster

MessageBox.Show() requires it to be a WinForms project as far as I know (there could be ways around it like referencing the right DLLs)

I am starting to guess your project is console or service based?