If I change a subroutine to a function, do I need to change codes that call the subroutine? For example, I have subroutine : Public Sub fillDropDownList(ByRef ddlPage as DropDownList). I need to do unit testing on it, so I changed it to a function: Public Function fillDropDownList(ByRef ddlPage as dropDownList) As DropDownList. Some of my webpages called this sub like this:
Dim cCommon As New
cAdminCommon
cCommon.FillPageDropDown(ddlPage)
ddlPage.SelectedValue = 100
I've got a program that has a text box with a list of files that are on any removable media. Suppose you launch the program and there's nothing in your CD-ROM drive. Right now, you'd get nothing, and you'd have to insert a disc and click a "refresh" button, which triggers a function that repopulates the list.
Is there any good way to call this function on the event that the user inserts/removes a CD-ROM from any CD-ROM drive? Also, inserting/removing external disks and flash drives? Without having to constantly poll the drives. Floppy disks aren't important to me.
Suppose I have a class that represents a product to be priced using one of a number of different pricing strategies. This pricing occurs hundreds of times per second, so to eliminate repetitive if/else statements I am instead using a delegate to launch the appropriate strategy, like so:
Private Delegate Sub PricingModel(ByVal params As PricingParameters) Private myPricingModel As PricingModel Private myPricingParameters As PricingParameters[code].....
But this doesn't look right to me (though it seems to work). Is there an accepted/better way of doing this? Or is this the standard way? Or is this just simply a doomed approach from the start?
Currently just started working with VS2008 I have a SQL script that is returning a number looking time in one of my columns (50625) which is 5:06:25 What I would like some help with is creating a function that would take this value and change it to a real time at some point I will need to do further calculation on these times so I need to be able to add or subtract these results.[code]...
I am having trouble with a blackjack game I am creating. I have buttons 1 - 13 (A-K) I have 5 Textboxes which when the above buttons are pressed displays the values in the textboxes. I also have one more textbox which adds up the values of the above 5 textboxes to give your Black Jack Total. The problem I have is if an Ace (11) is in one of the textboxes and the Total Value exceeds 21 i need to have the Ace (11) change its value to 1 instead.
textbox 1 - 5 will be the card values textbox6.text will be the total Value
I have tried......
if textbox6.text > 21 then and textbox1.text = 11 then textbox1.text = 1
This seems to work fine however it only solves the problem of an Ace (11) appearing in textbox1.text so i tried to repeat the code with the other boxes...
if textbox6.text > 21 then and textbox1.text = 11 then textbox1.text = 1 if textbox6.text > 21 then and textbox2.text = 11 then textbox2.text = 1 if textbox6.text > 21 then and textbox3.text = 11 then textbox3.text = 1
[CODE]...
However this does not work and my program freezes?
I have a question: How can I make a function or sub run inside a structure when a variable in this structure changes? As example I have this function: Public Structure Texture Sub New(ByVal TexturePath As String) Me.Path = TexturePath Me.Image = LoadImage(TexturePath) End Sub Public Path As String Public Image As Image End Structure
And somewhere this happens: Dim t As New Texture("path ooldfilename.tga") t.Path = "path o ewfilename.tga" I want it to automatically load the image when the "Path" variable changes. Is the only solution making an extra sub and run that? It would really decrease my code size if it changes on variable change.
if i got a function with a try cath block inside and the function should return an integer.how would i do it that the function can return me a the error message?public function test() as Integer
I have controls like buttons, textboxes and all on all the forms in my project, by applying Application.EnableVisualStyles() before Main() Thread starts the controls will have look of XpStyles.
Suppose if i need the Font Size for all the Buttons in my project i need to write the Font Style Property on each form... but this process is very long as my project is big
is there any logic that without writing code on all the forms to update the button Font Size..
This function doesn't work if I change the input argument 'pdu' from a string to an int.Would someone please help me figure out what to do here so that the checksum does not add the ascii value of the int argument but rather the actual integer value?I took out a few lines of the actual function but it adds the input argument to a packet sent out via TCP protocol.This function shows the integer value just fine in the string that gets encoded as a byte array. the checksum is wrong.!
''Public Function buildpacket(pdu As Integer) is what I want. Public Function buildpacket(pdu As String) Dim packet As String
I've been trying to convert my VB6 code to VB10, I'm stuck on how I should write it so I can pass a font name to my
function, So far this is what I have and not sure where to go from here. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
1) The first function (call it GetValues()) returns values in a SQL database as a list via a stored proc. One of the fields is DateTimeSubmitted. All of this data is displayed on my webpage using a repeater control. It works fine.
2) The second function (call it NiceDate()) I created to change the DateTimeSubmitted to a nice date such as "one minute ago" or "yesterday".
My problem is I have no idea which is the best part of the process to do the conversion (at point of data extraction or in pageload etc.) or in fact how to do the conversion.
I've been trying to reuse my bosses vb.net buildpacket code which he has successful used for Serial programming eg. SerialPort1.Write(buildpacket(useraddress,252,"0006","0") for the function listed below.My challenge.Create equivalent functionality for Socket BeginSend() which requires a byte array.Whether modifying the vb.net below or getting a c# equivalent to work, it has been repeatedly recommended to scrap the string concatenation approach for which I have to use Encoding.BigEndianUnicode.GetBytes() and then getting rid of extra bytes with zero values.
I'm lacking in imaging something different which would work for socket programming directly and allow me to eliminate all the hassles that c# integer conversions into string value that can be encoded trouble free.I would need to call the equivalent of the following that would return a byte array rather than a string with the following arguments
1. Source address (0-255) 2. Destination address (0-255) 3. Function code ("0001" through "0100") 4 Packet Data Unit (pdu - some integer value
I want to make an numerical integration method with takes in an analytic function and integrate it over a specific interval. For the numerical integration procedure I want to use some procedures in nr.com. The problem is that these are programmed in C++ and they uses functors to pass a function to the integration method. How can I do this in VB 2010?
I want to initialize the function (i.e. set a=1,b=0 for function y(x)=a*x+b) and then pass the function to the integration method. Then when the integration method call the function it only calls the function with one parameter (i.e. x since a,b is already set)
What is the best way to do this in VB2010?I want to make a general integration method where I can pass any single valued function and integration limits.
I have just started using VB, and from what I have found so far it seems like the tools you have is
- to us a delegate for the function - to use a lambda expression for the function - send a pointer/adressOf - to create a function class/structure and submit this to the function
As for now I am most inclined to create a function-class. But I am not really sure how.F.ex. I make different classes for each "uniqe function" I want to integrate, but how can I pass them to the integration function when I need to specify the argument type in the integration-function-call?This seems like a basic problem which applies to many Math operations, so I think it would be very useful to clarify this.
I'm trying to undersatnd the syntax of calling a funciton and it seem confusing when I'm using a web service in ASP.net. Maybe this question should be in an ASP forum, but it is a VB question. This simple web service allows you to type in your name and it response with an alert box with you name.
My question is, How can you call a function with 2 arguments when the function is only defined for one. I understand that the second argument is actually a method that handling the respons, but how can you interchange function arguments for methods and how do you know that there are methods for
I have a button that will type a message saying 'hello' in a message box, (if clicked on). And I want to know how to make another one that will change it to say 'Hello Word' (when clicked on ).[code]...
I am trying to convert a DLL function call which has the Callback function routine called within the DLL function call.The DLL function call signature is like this:
I'm using Visual Studio 2010 / VB / dot net 4.0, and I have a drop-down menu in my left column that switches resource languages for the end user. It reads like this:
--------English ------- <<- Engish is always the default top language option French | Spanish |
i wanted to ask how to make picturebox1 ,to which functions are already assigned, perform the same function as picturebox2 ,to which no functions are assigned.For example:I have already made picturebox1 and have assigned it alot of function like when play button is pressed then picturebox1.visible = true and when we press pause button picturebox1.visible = false. So now i decided to make a theme and have to remove the picturebox1 and want to allow the picturebox2 to havefunction of picturebox1.But when i disable the theme the function of picturebox1 should go back to picturebox1.
I need to execute a stored function in oracle or sql through vb.net. I created a command object. Depending on the database type(oracle or SQL) i am preparing the Command text as Select functionName(?,?,?,?,?,?,?,?) from dual; (For Oracle) Adding the parameter values of the function. Now performing the ExecuteScalar which is not working saying invalid parameter. This works with ODBC connection string. But ODBC doesn't with 64bit. My Requirement: Code should execute a user defined stored procedure by taking the values at runtime.
I'm currently working with a client's VB.Net code, which was developed for them by a small development shop a few years ago and which they purchased and have been maintaining and uprgrading since. This client's primary developer is out on indefinite (likely permanent) medical leave and I'm now filling in until they bring in a full timer (as I'm a contractor here). My current task is to add some functionality to a the VB.Net code they purchased. I'm finding practices and techniques in the code that absolutely baffle me and can't make the code do what I want. I'm starting to wonder if it's me and was hoping to get some thoughts on the code I've encountered.
For example: Setting a variable to accept the result of a function by calling the function with many parameters, clearing the parameters in the function, setting them to some value, calling another function with those new values, then never using the values returned by the functions. I'll add a code snippet in the first comment since this is already getting long.
How can I call a function from inside another function and suspend the calling function until the called function is finished? I hope I can get some replies because I don't know how to ask the question and make sense:).
Anyway what I am trying to do in steps:
1. The user clicks button1 which triggers the click event. 2. From the click event I call a function 3. I then pop-up a form, that has instructions for the user to read. 4. After the user has read the form he will click the "Done" button and return to the calling function.
The problem is the the calling function continues to execute. I want to stop execution of the calling function until the users clicks the "Done" button on the instruction pop=up. I know I can use a msgbox but the instructions can be lengthly and does not look good in a msgbox.
I have tried the Call method with return in the "Done" button click but I can make that work. I also tried a goto statement but I can get that to work either. In the call statement I said call frmInstruction.show() and it got there but as I said the calling function continued to execute.
ive two custom controls, which are used to draw and edit etc...(like paint but customized....) i want to save their images with a single click....So im using the Getimageofcontrol function to do it....its code is below:::
Public Function GetImageOfControl(ByVal c As Control) As Image Dim rc As New Rectangle(c.PointToScreen(c.Location), c.Size) Dim i As Image = New Bitmap(rc.Width, rc.Height)[code].....
and the code to call this function for saving the images is simply.. ...
I have a function where I am performing a lot number of database operations inside a Sub. The operation when called directly like:ExecProcess()
takes about 11 seconds to run.However, if I create a Delegate, and call the sub using BeginInvoke(), the very same process takes over 40 seconds to execute.Here's the threaded code:
Protected del As ProcessDelegate Protected Delegate Sub ProcessDelegate() del = New ProcessDelegate(AddressOf SELocal.ExecJob) Dim cb As New AsyncCallback(AddressOf Me.ExecJobComplete) del.BeginInvoke(cb, del)
Anyone know what may cause a function to take longer inside a new thread, rather than calling directly?