Run code from IDE

  • Thread starter Thread starter Bryan
  • Start date Start date
B

Bryan

How can i run a bit of code straight from the IDE? Right now i make a
temporary button and put the code behind that, then i run debug mode
and click on the button. Is there a way to highlight some code and
tell it to run that? Is there a "scratchpad" type window like in VBA
where I can write some simple code to be executed? Thanks for the help
in advance
 
I wish there was a way to run a single sub or function, or even to open
a form without having to set it as the default start up form. Maybe I
am missing something When you guys want to test little things or run a
little maintenece procedure, what do you do?
 
OK, well just because you are writing a windows applications it doesent mean
you need a user interface. You can remove the form and use a sub main in a
module. you can put your code in there.
 
Bryan,

I just open them as form, keep the default name and clean all with those
default names up time by time.

:-)

Cor
 
|I read your article, but without being rude in any way, I dont see that
your methods in step 3 or 4 are functionally any different from what you say
is cumbersome in step 1. In fact I think its more cumbersome and has no
particular advantage wrt trying out a snippet of code.

Things changed with the advent of .NET and people are just going to have to
get over it. In all honesty when you are writing code everyday for seven
hours a day, you get better at preventing compiler or runtime failures and
its not such an issue.
 
I wish there was a way to run a single sub or function, or even to open
a form without having to set it as the default start up form. Maybe I
am missing something When you guys want to test little things or run a
little maintenece procedure, what do you do?

I put it in a button click event or in form load.
 
|I read your article, but without being rude in any way, I dont see that
your methods in step 3 or 4 are functionally any different from what you say
is cumbersome in step 1. In fact I think its more cumbersome and has no
particular advantage wrt trying out a snippet of code.

My experience is this:
The project I'm working on takes about 10 seconds to compile and about
30 seconds to start. This is 40 seconds. Just to see whether, for
example some regular expression I wrote is correct. Opening Snipped
Editor, pasting two lines of code and executing takes me about 10
seconds. With macro IDE it is even faster.
 
40 seconds is a long time, I think perhaps you may want to think about
compiling some of your code into libararies as this is way too long.
 
40 seconds is a long time, I think perhaps you may want to think about
compiling some of your code into libararies as this is way too long.

Yes. The project is DLL (VS add-in) and most of the start time takes
launching of another VS instance which is DLL's host. I agree that with
normal programs this is not an issue.
 
Create a public sub in a module and you can call it from the Immediate
window. Paste codes you need to test there.
 
#1 - When you run the code, the program automatically recompiles so it's
pretty transparent.
#2 - He's not stating he doesn't want to have to recompile.
#3 - How are you contributing?
 
Yes, he has implied he didnt want to recompile, if you read up he has
compared the immediate window in pre-.net basic where code was interpreted,
and if you read-up, you will see I have already contributed, and this post
is a continuation of that contribution. Compilation and load can take up to
a minute if you are writing large solutions, but perhaps you're still on
"Hello World"?
 
Yes I agree, you contributed with code in sub Main of a module and I suppose
your super solution doesn't require compilation? You should be writing
Hello World if you ask me.
 
I wish there was a way to run a single sub or function, or even to open
a form without having to set it as the default start up form.

My response was accurate, you simple didnt read it.
 
OK, well just because you are writing a windows applications it doesent
That was your response but note how does that differ from mine? Try
returning something from Sub Main. As he stated, a way to run a single SUB
or FUNCTION and my solution was to create a PUBLIC SUB or FUNCTION in a
module so you can call it directly from the immediate window. And what was
your response to that? How does this help? It still needs to be compiled.
Hello World? Who didn't simply read what?
 
As a matter of fact you although you cant return anything from a Sub, you
can alter object passed to it, but that is not the issue.

He asked two questions.

1.) Could he run a function from an immediate window.
This has been discussed to death and there is no point talking about it
further.

2.) Could he simple call a from a function ?
I wish there was a way to run a single sub or function, or even to open
a form without having to set it as the default start up form.
You can optionally run Sub Main and open up a form if required. Some windows
applications dont require a user interface so this would be appropriate in
such cases.
 
Back
Top