|
There is no way to embed a VB6 app inside a .NET app and expect it to run. It must be a seperate file.
Communication is going to be a huge PITA. You cannot call its functions or anything else, unless the VB6 app exports them through COM. A normal VB6 app cannot do this unless it's written as an ActiveX server.
As for the controls that work in VB6 and won't work in C#, I doubt it. I haven't come acrossed a control that didn't work in the .NET world, but did in VB6. I have, however, come acrossed some badly written controls that I didn't even bother with in the conversion to .NET. I either got an updated control or just wrote an equivalent control myself and replaced it.
Your best solution is to scrap the VB6 app entirely and rewrite in C#. Why have 2 different runtimes loaded, VB6 Runtime and the .NET Framework, for your app to work?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello everybody.
I've just started with C# programming and I'm new here. I've only studied C# for half a term so you can say i can't so much about programming. I love to program, but anyway to my question.
I've just done a small game and I would like to have a highscore table that is saved everytime I close the game.
everyone here seems to be better than me so this is propably kind of easy for you guys ha?
Tutorials or just type the code here maybe?
any help is appreciated.
thank you.
Simon an amateur in c# programming.
|
|
|
|
|
All you have to do is write your data to a file on disk. You can do this easily using System.IO.File.
MSDN has 101 C# examples covering everything from UI development to dealing with files & folders on disk; these tutorials should help you get off to a good start. The tutorials are available here[^].
|
|
|
|
|
Thank you.
Simon an amateur in c# programming.
|
|
|
|
|
|
How to set string myString= javascript_string; where myString is a string created by c# and javascript_string is a string created with java script on the same form
|
|
|
|
|
You need to submit the JavaScript string so that the server (aka C#) has access to it in the post-back. Try adding a TextBox and setting it using JavaScript. Then, when you submit the form, you should get the new value.
Michael Flanakin
Web Log
|
|
|
|
|
Parsing a html document in C# using mshtml object works very slow.
Why is this happening ? Is it possible to avoid it ?
|
|
|
|
|
We haven't seen this. Have you run your code through a profiler? Perhaps there's something on your end causing the problem.
|
|
|
|
|
What do you mean by a profiler ?
I have made a test end code - a code that simply gets recursively all children of each node and that runs through each attribute of each node. Even very simple html pages run in 1-2 seconds. However the same pages, with the same algorithms, run instantly on VB6 or VC++ 6.
Can you provide me a simple C# project that does the same thing and runs instantly on html pages of medium complexity ?
|
|
|
|
|
Go download the ANTS profiler trial[^], run your project with it, and it'll tell you what's taking time.
My guess is one of 3 things; you're modifying the DOM document (which is not too fast), or there's a bug in the interop assembly (microsoft.mshtml.dll), or you're not caching your references to the DOM objects. Run a profiler and see what's taking up time.
|
|
|
|
|
1. The program doesn't modify the DOM for sure.
2. Probably there's a bug in the interop.
3. I am caching the reference to DOM objects (i.e. access the objects always through a local object).
I have made a simple COM in VB6 that takes as input a HTMLDocument object and runs the same algorithm as the one written in C#. If it's run by a VB6 program - it runs very fast.
If it's run by C# - then it runs slowly, similar to C# code. But ! if the VB6 com receives the URL of the page, loads it itself and then calls the function that parses it - then it works very fast again.
I think this is due to some kind of .NET object wrapper.
|
|
|
|
|
I have run the profiler. The biggest part of the time is spent on accessing/enumerating (with Foreach, or with IEnumerator) all children or all attributes of each node.
|
|
|
|
|
Try enumerating them with a regular for loop. Also, cache references to these if you're accessing them multiple times. You may also want to profile mshtml.dll when you run this to see if there's anything odd going on there.
|
|
|
|
|
I am sure that if there's something wrong, then it's wrong with the mshtml.dll . As I said before, if I run a VB6 COM that uses the HTMLDocument from C# (received as a parameter to its function) - then it runs slowly, but if the VB6 COM doesn't take the C# HTMLDocument (load the page itself) - then it runs fast.
How to run the profiler on mshtml.dll ?
As you said at the beginning - you didn't encounter such things as slow running. Have you made a similar module or code that parses a HTMLDocument object using mshtml ? If so - what VS.NET did you use , and on what windows ?
Thanks.
|
|
|
|
|
When you run the profiler (assuming you're running Ants profiler), in the profiler wizard, select "Profile all .NET methods", which should give you some results on MSHTML.
|
|
|
|
|
I've tried to access the nodes by indexes (not through enumeration) - doesn't help much.
Ran the profiler on mshtml.dll too, and it showed that most time is spent on accessing the attributes and children of nodes.
Thus there's only one possible reason - either .NET works slowly when accessing mshtml elements, either the mshtml is generated wrong (which I doubt).
|
|
|
|
|
This is the C# code that I used for tests (doc is a HTMLDocument variable):
ArrayList nodes=new ArrayList();
mshtml.IHTMLDOMNode nod;
children=(mshtml.IHTMLDOMChildrenCollection)doc.childNodes;
foreach(mshtml.IHTMLDOMNode node in children) nodes.Add(node);
mshtml.IHTMLAttributeCollection attributes;
for(int a=0;a
|
|
|
|
|
How can I write a prog to Pop up a message box notifying me about an meeting ,refering to the calander of the outlook, half an hour before meeting.
Also I want the system to take data from Data Base connected to the Outlook and send me an SMS 30 mins before meeting..............
Can you help me out please.......
Thanx And Regards
Arjo
Arjo Gupta
|
|
|
|
|
Use the Outlook interop dlls to interop with Outlook and retieve Outlook data. See the MSDN article here[^] for further information.
|
|
|
|
|
I have did a program such that , i will have two text box name and age in my form..and a button..so that when the values entered r in the text box..a xml file is created with those data...
and my coding is as follows.
Inside the burtton click, th e coding is as follows
//create a dataset
DataSet dataSet = new DataSet();
//read the schema
dataSet.ReadXmlSchema("d:\\Menu.xsd");
//create a new row
DataRow newrow;
newrow = dataSet.Tables[0].NewRow();
//enter the values
newrow[0] = Convert.ToInt32(txtName.Text);
newrow[1] = Convert.ToInt32(txtAge.Text);
//add the row to the dataset
dataSet.Tables[0].Rows.Add(newrow);
//write the data to a xml file
dataSet.WriteXml("D:\\myData.xml", XmlWriteMode.WriteSchema);
MessageBox.Show("saved");
Now i have one doubt..
ie, the program which i did ..now ..in the form...when i am giving data as
for
name: john
age:22...
now myData.xml wil be saved with those data ... Now if i am clearing those vaues in th textbox and adding some other data... that should be added without deleting the previous data... and also if i am entering again john..it should show that already it exists....
please say how to do this...
|
|
|
|
|
Before writing to the XML file, read the existing one into a DataSet. Before writing a new name & age to the XML file, first make sure its not in the dataset. If it is, show a box saying it already exists.
That said, if you're going to be storing lots & lots of data like this, I recommend you use a database rather than XML files. XML files are good for configuration, settings, storing discreet, concise bits of information in a human readable format. If that's not what your goals are, you should choose another tool such as a database to store your data.
|
|
|
|
|
Hi
I have did a program such that , i will have two text box name and age in my form..and a button named save. so that when the values entered r in the text box..a xml file is created with those data...
Now I can able to create one set of values…. No what I need is that when again some other value is entered in the textbox. It should also be written in the xml file..but without deleting the other. I mean it should append on the other..
For example: first I entered forst as john and 22 for name and age ..it will added in the xml file..no again if I enter charu and 23 as name and age..
Now xml should have john and 22 as well as charu and 23…
And also one more thing is that if I again enter John. It should give a message that it has already been entered. No values should be repeated again. Please help me to do this…..
The coding which I did is as follows.
In side the button click
//save Button
private void button1_Click(object sender, System.EventArgs e)
{
DataSet dataSet = new DataSet();
//read the schema
dataSet.ReadXmlSchema("..\\..\\PlaygroMenu.xsd");
//create a new row
DataRow oValues;
oValues = dataSet.Tables[0].NewRow();
//enter the values
oValues[0] = txtName.Text;
oValues[1] = Convert.ToInt32(txtAage.Text);
//check for duplication
bool hasalready = false;
foreach(DataRow row in dataSet.Tables[0].Rows)
{
if(row.ItemArray[0].ToString().Equals(txtID.Text))
{
hasalready = true;
}
}
//
if(!hasalready)
{
//add the row to the dataset
dataSet.Tables[0].Rows.Add(oValues);
//write the data to a xml file
dataSet.WriteXml("..\\..\\resultdata.xml", XmlWriteMode.WriteSchema);
MessageBox.Show("Saved");
}
else
{
MessageBox.Show("Already Exists");
}
}
private void Form1_Load(object sender, System.EventArgs e)
{
DataSet dataSet = new DataSet();
//read the schema
dataSet.ReadXmlSchema("..\\..\\Menu.xsd");
System.IO.FileInfo file = new System.IO.FileInfo("..\\..\\mydata.xml");
//check whethere there is result xml file...
if (file.Exists)
{
dataSet.ReadXml("..\\..\\resultdata.xml");
}
}
Please help me to do this..
Dhol
|
|
|
|
|
Hi,
I am planning to use this approach please let me know if there is a problem in this approach..
Same code can be written for C# as well..
Thanks and Best Regards,
Shahid
// This example shows how to create an Object* containing task
// information, and pass that Object* to a task queued for
// execution by the thread pool.
#include "stdafx.h"
#using
using namespace System;
using namespace System::Threading;
// TaskInfo holds state information for a task that will be
// executed by a ThreadPool thread.
public __gc class TaskInfo
{
// State information for the task. These members
// can be implemented as read-only properties, read/write
// properties with validation, and so on, as required.
public:
String* Boilerplate;
int Value;
Thread *tHandle;
// Public constructor provides an easy way to supply all
// the information needed for the task.
TaskInfo(String* text, int number)
{
Boilerplate = text;
Value = number;
tHandle=NULL;
}
};
public __gc struct Example
{
// The thread procedure performs the independent task, in this case
// formatting and printing a very simple report.
//
static void ThreadProc(Object* stateInfo)
{
try
{
//Do Always
TaskInfo *tInfo= (TaskInfo *)(stateInfo);
tInfo->tHandle = Thread::CurrentThread;
TaskInfo* ti = dynamic_cast(stateInfo);
Thread::Sleep(10000);
Console::WriteLine(ti->Boilerplate, __box(ti->Value));
}
catch(ThreadAbortException *Te)
{
Console::WriteLine(S"Thread Aborted by Main Thread{0}",Te->ToString());
}
}
};
int main()
{
try
{// Create an object containing the information needed
// for the task.
TaskInfo* ti = new TaskInfo(S"This report displays the number {0}.", 42);
// Queue the task and data.
if (ThreadPool::QueueUserWorkItem(new WaitCallback(0, Example::ThreadProc), ti))
{
Console::WriteLine(S"Main thread does some work, then sleeps.");
// If you comment out the Sleep, the main thread exits before
// the ThreadPool task has a chance to run. ThreadPool uses
// background threads, which do not keep the application
// running. (This is a simple example of a race condition.)
Thread::Sleep(1000);
//Abort the Thread started
ti->tHandle->Abort();
Thread::Sleep(15000);
Console::WriteLine(S"Main thread exits.");
}
else
{
Console::WriteLine(S"Unable to queue ThreadPool request.");
}
}
catch (...)
{
Console::WriteLine(S"Unknown Exception Occured in Main");
}
return 0;
}
;
|
|
|
|
|
I don't think aborting threadpool threads is a good idea. That apart, your code is susceptible to a race condition between assigning and using tHandle.
tInfo->tHandle = Thread::CurrentThread;
is not guaranteed to run before
ti->tHandle->Abort();
so you'll get a NullReferenceException if that happens.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|