|
you want to force the caller of your function to hold the passed value in a special named variable!!!
ok, maybe you find my comment annoying - but it seems you have to learn some basics about "functions", "parameters", "value types" and "reference types". If you do, such questions or "solutions" will never come to your mind, and it's worth the cost in the long term!
Your problem, if I got it right, is solvable by good old: "another level of indirection"...
|
|
|
|
|
Well, First, I don't know in which category I can put your answer, it is annoying as you said, "Yes", but I will not kill my self if that is your purpose :P
Second, I don't know if you read the whole conversation, that what I am asking for can be done in C, and Foxpro, and Python so, knowing the basics of the function or parameter will not help much. If you work in another programming language such Foxpro or Python, I guess it is normal to check if that can be done in vb.net such as these 3 language above.
Third, I know to overcome what I am asking about and that by using old trick being used since vb6 old days which is the collection or hashtable
Dim par1 As New Hashtable
par1.Add("'USA'","address")
myfunc("customer",par1)
Function myfunc(ByVal TableName As String,FieldNameValue As Hashtable)
Dim sql = "SELECT * from " + TableName + " WHERE " + FieldNameValue.Item(key:=FieldNameValue.Keys(0)) + " = " + FieldNameValue.Keys(0)
MsgBox(sql)
End Function
As I said, I am building my framework, asking for some technique if it exist or no, may change the whole idea of my coding in case the answer was "yes"
Forth, this is personal question to you.
Since old days of vb6 and till 2010 of each release, people asking such question, and we got always the same answer "No", ok, but why? because vb is not a scripting language. arrrg, so? why not include such powerful technique in the vb? that will cause Microsoft to lost money regarding it supported in c? why not vb after 4 .net release does not has it? it should be piece of cake for the developer with the existing of that nasty reflection in there hands. That will help a lot of building dynamic Sql statement and building code on the fly and execute it. Security issue? then remove it from c.
my question here not to Microsoft, but to you.
Why you are against it?
|
|
|
|
|
Thank you for your long reply.
I've read the whole conversation, and I'm aware this things can be done in other languages - in C you would do it with the pre-processor... others mentioned it.
So you want't to do this now with .Net, - This lead me to my "not so nice" answer. I just wanted to mention, there a good reasons not to use pre-processors with "textual replacement" any more. If you are planing your framework, you shouldn't force the callers to know which variable names to use, so I said "learn about parameter passing".
@4: This is not so difficult: "Powerful technique" - is the wrong word for "textual replacement" - this is what you wan't. So personally I'm happy with no pre-processing and textual replacement any more. I was a C/C++ programmer long enough to know about the power of macros, but I never missed the nasty debugging (real compile-time type-checking is not possible for the compiler).
Today I would use a "hashtable/dictionary - workarround" you showed, or generate the code on the fly, or use reflection - but the best you can do - check your requirement and think realy hard if you need this. I'm for sure not the smartest person on the planet - but I'm programming for a living for enough years now to "smell" a bad solution. I wanted to do the same thing in the past, but I resisted, and found a better solution. -Again, please don't be angry about my "learn about basics"-statement.
I hope you find a nice solution for your framework and users!
greetings
|
|
|
|
|
johannesnestler wrote: check your requirement and think realy hard if you need this
NO I don't need this
I got your answer very clearly.
I am not an expert in .Net, I moved to it having in mind that it had every thing. I mean by every thing that it has collected all the technique in other languages.
I asked many question in msdn forum, most of them the answer was no.
can that be done:
dim x as myclass
x.Find("customers", <-- after this the intellisinse get list of all fields from sql server so I can list them. The answer was NO
Can I have multiple copy of vs2010 where each one start with it is own setting such as syntax color and loading of extension. the answer was NO
Can I list the local variable inside the function/sub i am currently working in, the answer is NO
These question is not for you or any one to answer, i am just telling you that in my mind I had overdose of expectation about .net, now, I will say ".Net is very powerful, but you should know it is limitation" so that i am asking this kind of question.
I hope you did not get bored with my second long answer, and thank you for you second explanation which I got it 100%
Cheers
|
|
|
|
|
some thoughts:
.NET and it's tooling is a programming environment like many others. If you want to use it's power, you have to use it in the right problem domain. .NET has a huge "problem domain" it can be applied to. You can write Web/Desktop/Mobile/Database-Apps with one Framework. You can use different languages, etc.
You shure don't get "every thing" from it, but i think it's very much compared to other frameworks.
What you have to know is the same for every kind of programming - How you solve your problems with it.
As an example - for all the problems you mentioned there maybe is an solution.
* You can implement your own intellisense behavior, but magic is impossible...
* An VisualStudio-AddIn would do - all IDE settings live in one file (you can export them...) - Shure you need for using AddIn...
* The intellisense lists all local variables you have defined... ? If you use the rigth naming conventions you can tell which are the "global" ones.
What I want to say is: Create some projects, look how others solved common programming problems in .Net - and learn from it. If you are smart in solving problems, you will always find your solution. If you wan't to change the IDE to your needs, do it - if you don't like it- make your own. (easier than it sounds!) - .NET clearly gives you the power.
You will always find limitations in a technology - but .NET is so complete,open and clear - you can bend it to your will!
|
|
|
|
|
Hi again
johannesnestler wrote: * You can implement your own intellisense behavior, but magic is impossible...
That mean, creating my own plug-in VSIX, and use it. And that is not an easy task which I will never do since I can live without it. I prefer wasting my time on something new for my project to the customer that earn me money. I thought such thing can be done in 5 min.
using Enum? Very very very bad idea. so, No answer
johannesnestler wrote: * An VisualStudio-AddIn would do - all IDE settings live in one file (you can export them...)
That work for loading the syntax color and setting the programming language environment, but not for choosing which extension to be loaded where most extensions require to restart VS. Once again I thought that is easy to do by few clicking.
johannesnestler wrote: * The intellisense lists all local variables you have defined... ? If you use the rigth naming conventions you can tell which are the "global" ones
I got the same answer from msdn, that is not an answer more than workaround. Once I get advised not to use naming convention since the .net environment is smart enough to tell where is the error when assigning wrong type to a variable. And now I had to use to solve my simple question which I thought it is (BY DEFAULT) should be there.
I had to change what is in my thoughts
johannesnestler wrote: .NET clearly gives you the power.
I consider the above as an answer to all my questions. .Net gives you the power to any thing, but do it your self.
Nice talking to you
|
|
|
|
|
Sam Martini wrote: So, If I used Byref, (I am guessing here) The parameter inside the function header should have pointer/link to the calling variable
No, the pointer is not to a variable, but to a memory location. At runtime, variable names don't exist.
|
|
|
|
|
Hello Dave
Dave Kreskowiak wrote: At runtime, variable names don't exist.
Thanks, I got it now. although it still a bit fuzzy of how other language can do it.
"Understanding" is always hard part of being a programmer
|
|
|
|
|
... of how other language can do it:
1. Pre-processor = textual replacement in the code file before(!) compiling
2. Interpreted languages - reading your code...
...
Compiled to native processor instructions: No variable names, or logic depending on it ...
|
|
|
|
|
But if you were a C dinosaur, you could write
#define log(x) fprintf(stderr, "#x = %g\n", x);
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
which I used to do quite a lot.
the C pre-processor was a powerful tool, and at least one CP member is using it even on C# code!
|
|
|
|
|
Luc Pattyn wrote: which I used to do quite a lot.
So did I!
Luc Pattyn wrote: the C pre-processor wasIS a powerful tool
ftfy
Luc Pattyn wrote: at least one CP member is using it even on C# code!
Where's the :shudder: smiley when you need it?
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
You rang?
It's just a text processor; you can use it with pretty much any text file.
|
|
|
|
|
PIEBALDconsult wrote: It's just a text processor; you can use it with pretty much any text file.
I beg to differ.
IMO it only works rather well for you because C# and C/C++ are sufficiently related syntax-wise. The pre-processor has to understand where it should and shouldn't try and apply define and macro substitutions; it should not modify stuff inside comments and string literals, so it knows about /* and // comments, and it knows "abcd" and "ab\"cd" are untouchable. If (horresco referens) you feed it VB source code, you won't like the outcome.
|
|
|
|
|
Peter_in_2780 wrote: But if you were a C dinosaur
I am C egg dinasaur.
I know nothing about C, except it is very powerful and very very hard
|
|
|
|
|
|
I guess it is a common question with common answer as well
|
|
|
|
|
I have a Shockwave Flash Object (named webFlash) in my form. I'm trying to use StretchBlt to magnify the object. Ideally I would like to push a button and have it replace the Flash Object on my form with the magnified version.
Any help would be appreciated, even just documentation on how to use StrechBlt because I can't find anything on it. Thank you.
The code below I found browsing the web. It was originally for a mouse cursor, but I'm trying to adapt it.
Private Declare Function GetCursorPos Lib "user32" (ByRef lPointCoordinateoint As PointAPI) As Integer
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lplWindowName As String) As Integer
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Integer, ByVal hWnd2 As Integer, ByVal lpsz1 As String, ByVal lpsz2 As String) As Integer
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Integer) As Integer
Private Declare Function StretchBlt Lib "gdi32" (ByVal hdc As Integer, ByVal X As Integer, ByVal Y As Integer, ByVal nWidth As Integer, ByVal nHeight As Integer, ByVal hSrcDC As Integer, ByVal xSrc As Integer, ByVal ySrc As Integer, ByVal nSrcWidth As Integer, ByVal nSrcHeight As Integer, ByVal dwRop As Integer) As Integer
Private Declare Function GetDesktopWindow Lib "user32" () As Integer
Private Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Integer, ByVal hdc As Integer) As Integer
Private Structure PointAPI
Dim X As Integer
Dim Y As Integer
End Structure
Dim PointCoordinate As PointAPI
Dim lWind As Integer
Dim lDesktop As Integer
Dim lButton As Integer
Private Sub Video_Mag_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Video_Mag.Click
Dim lWind As Object
lWind = GetDesktopWindow()
lDesktop = GetDC(lWind)
lButton = GetDC(Me.Handle.ToInt32)
Timer.Enabled = True
End Sub
Private Sub Timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer.Tick
GetCursorPos(PointCoordinate)
' ? > Origin X > Origin Y > Size X > Size Y > ? >
StretchBlt(lButton, _
webFlash.Location.X + webFlash.Width + 1, _
webFlash.Location.Y + webFlash.Height + 1, _
webFlash.Width, _
webFlash.Height, _
lDesktop, _
webFlash.Location.X + webFlash.Width, _
webFlash.Location.Y + webFlash.Height, _
124, 60, &HCC0020)
End Sub
|
|
|
|
|
hi
I am beginner in programming Visual Basic and i use the visual studio 2010 ultimate
Almost finished my simple program
__________________________________________
just two button's left was
How to make a button that will copy two files and put them somewhere else
I have the two files in the
C:\Program Files\Imust
One. Dll and the second. Exe
I want a button to copy the files and places them in
C:\WINDOWS\system32
How?
_________________________________________
and the other button
system.diagnostics.process.start (C:\Program Files\Imust\392.exe)
is there's anyway to run 392.exe without path ?
_________________________________________
is there any list of usefull code's ?
______________________________________
thank
|
|
|
|
|
mshome77 wrote: I am beginner in programming Visual Basic and i use the visual studio 2010 ultimate.
Is this normal to pay around 4 - 5k € as beginner?
Greetings
Covean
|
|
|
|
|
no it not normal
that's way there is free trail
|
|
|
|
|
mshome77 wrote: How to make a button that will copy two files
You need to spend some more time learning the language and how there is no direct relationship between a button and a copy action.
It's time for a new signature.
|
|
|
|
|
Arg so many things wrong here.
First of all under vista / windows 7 the c:\windows\system32 map is protected and your program shouldn't be trying to copy anything in there (least of all a dll and a exe)
Second as Richard said a button has no relation to a copy (there is no such thing as a copy button)
A button has a click event in which you write code (code that can then copy your files).
(for that look at the system.IO.File namespace)
Third, you should never use absolute path's in your program, either use predefined paths such as the users temp directory or use a setting file where you store these path's.
As a last let me give you some pointers as how to ask a question here.
Don't just ask for code, show us what you have done, tell us what the code is supposed to do and what it is actually doing.
If there are any errors post them (but you'll have to write code before you can get any errors of course)
|
|
|
|
|
see below
modified on Tuesday, August 24, 2010 1:37 PM
|
|
|
|
|
Tom Deketelaere wrote: First of all under vista / windows 7 the c:\windows\system32 map is protected and your program shouldn't be trying to copy anything in there (least of all a dll and a exe)
I'll second that... I'd go one step further and say no matter what OS, or version thereof, files should not be copied to the folder where system files reside. Just a bad practice IMHO.
|
|
|
|
|