VS 2008 - Run Function Or Sub At Structure Change
May 11, 2010
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.
View 3 Replies
ADVERTISEMENT
Aug 23, 2009
I'm having a little trouble working with structures and using a counter for the same structure. my structure gets its data from a text file which i readoff and assign ok. Here's part of my code
[Code]....
View 9 Replies
Apr 25, 2010
I'm having a problem that's driving me crazy; I can't understand how to convert the XML structure into a class structure (that I want to use to hydrate a XML document).
The XML document looks like this:
xml
<?xml version="1.0" encoding="utf-8"?>
<artists xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns="http://www.spotify.com/ns/music/1">
[code]....
View 2 Replies
Apr 25, 2010
How can you make a function/sub change the inputvalue?
As example:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim testval As Integer = 1
[Code]....
View 6 Replies
Apr 16, 2012
I have problem about how I call a function on DLL to get data from a structure. Have a C++ example about how it's works the library, and I want to use it on vb.net. his is the working c++ example:
Declaration:
BOOL (WINAPIV* MyFun)(DWORD start1, DWORD stop1, P_RESULT pResult, PDWORD pTpNum, myCALLBACK lpFunc) = NULL;
Call:
// pStruc = RESULT structure
// TrpNum1, TrpNum is ULONG
ULONG TrpNum1=0;
MyFun(Start,Stop,pStruc+TrpNum,&TrpNum1,&myCB);
Callback:
void __stdcall myCB (RESULT *pStruc) {
printf ("%.3f", (double)pStruc->val1);
tpn++;
[Code] .....
The error is this: "Attempted to read or write protected memory. This often indicates that other memory is corrupt."
View 1 Replies
Apr 1, 2009
I am attempting to create a generic function that the students in my introductory VB .NET course can use to search a single dimension array of a structure.[code]...
My question is: Is there a way to reference the individual structure fields in the array from inside the function? I was trying to make it generic so that the student could simply pass their array into the function - their structure may be named differently than mine and the field names may be different.
I suspect there are other ways to deal with this situation, but I was trying to keep it to just a simple single-dimension array of a structure. I don't think it is possible to do what I want, but I wondered what others thought.
View 5 Replies
Apr 24, 2012
I've this code, but there is a problem with setting values. I get "null object" error. how to work properly with functions.
Public Structure Results
Dim Nickname As String
Dim Result As Integer
[Code].....
View 5 Replies
Dec 22, 2009
I want my function to return a value of a structure. The function is supposed to change the values and then return the answers in one structured value. Here is my code... as you can see it does not work... it needs a LOT of things. I placed question marks were i am really lost.
[Code]...
View 13 Replies
Nov 21, 2010
Say I do this
Public Function CheckWebCamVF() As BusinessProfilesBO.VFCheck
checkwebcamVF.isactive = true
return checkwebcamVF
[code].....
I seem to be getting null referance errors using the first one.I am trying to get my code as fast and as correct as possible
View 3 Replies
Nov 7, 2011
I'm a beginner when it comes to Visual Basic coding and I need some help with an error I'm getting. I'm trying to pass a structure array to a function to figure out a student's grade. I'm getting the error that 'QuizOne' is not a member of System.Array. Here is my code:
[Code]...
View 3 Replies
Feb 2, 2012
I have a structure to hold a student name, an array to hold 5 test scores, and an average score. I have created an a array of structures for 6 students. User input is setup through text boxes. I want to calculate the average for each student. I have made a function to do this. What I am having trouble with is how to pass the array of test scores to the function.
Here is what I have so far:
CODE********
Public Const intMAX_STUDENTS As Integer = 6
Public Const intMAX_NUMTESTS As Integer = 5
Public student(intMAX_STUDENTS - 1) As StudentData
[Code].....
View 3 Replies
Nov 25, 2010
I am trying to do a simple program where I have a public structure and public function in a code file, the problem is I want to return two integers. Here is the code from my code file.
[Code]...
View 7 Replies
Sep 24, 2010
I have a windows app that references a web service I created. In the web service, I created a function that needed to return more than one value. Because of this, I created a public structure in the web service:
Public Structure MyRecordSet
Public lstOfDataInRecord As List(Of String)
Public iNumberOfRecords As Integer
End Structure
Here's the function - the return value is MyNewRecordSet:
Dim MyNewRecordSet As MyRecordSet <WebMethod()> _
Public Function GetDataReturnList(ByVal sql As String, ByVal sTableName As String) As MyRecordSet
MyNewRecordSet.lstOfDataInRecord = New List(Of String)
[Code] .....
Anyway, I see it's a conversion issue, but not sure how to resolve it. This is my first attempt to use a public structure in a web service and receive a return on it from my app.
View 1 Replies
Aug 27, 2010
How do I change the program path '"logic.txt", "G:"' in the code below to the OpenFileDialog.FileName? Cos when I tried it, I receive String conversion errors and I tried altering the codes but it didn't work out well. [code]...
View 1 Replies
Nov 5, 2011
So I have an array which holds instances of a structure. The structure contains various string properties.
I'm looking to modify each instance of a structure within this array by doing the following:
For Each stuInstance As StuInstance In arrStuInstances stuInstance.strCarName = "Benz"
But I found that this in fact fails to really change it permanently. If I do the following loops in the given order:For Each stuInstance As StuInstance In arrStuInstances
[Code]...
View 2 Replies
Mar 21, 2009
I have created two structures, one named "Product" and the other named "Item". These structures are quite similar but are at the same time quite different from each other. The structure definitions are as follows. Ultimately, I declare arrays in my containing class which access these structures as a type. Their declaration: "Products() as Product" and "Items() as Item". All has been fine and dandy until one day, I go to change the items Enabled() values, and something happens. Not only does it change the Items(index).Enabled(index) value, it does it on the corresponding Products(index).Enabled(index) value, even though it was never specified to do so. Also, nowhere in my coding have i defined this sort of thing to occur. It is rediculous, because I watch it happen. I turn on the watch window, and debug one step at a time, and every time, I watch the Item line step, I look down at the arrays of products and items, and both values have changed. How do I get this to stop, and only change the Item.Enable value??
<Serializable()> _
Public Structure Product
Public Name As String
[code]......
View 2 Replies
Jul 9, 2010
I develop in VB and often I'm writing long TSQL statements in SSMS but getting them into VB is a bit of a pain. I like SSMS during development because I can change the query / structure and test it when there are problems. Some of them become stored proceduresand some of them I just keep in the code.
I like keeping them in the code because when I have a problem with something, I can GREP my projects directory and find the code that does something (that I've forgotten) or someone asks something about how something works, I can look it up. I've yet to find a GREP for stored procedures. Is there such a thing?I've read in a "best practices" white paper how we're not supposed to concatenate super long strings with & _
[code]...
C# handles these things much better than VB. I'm wondering how I can keep my code together during development and searchable later. I had my hopes up when VS 2010 offered implicit line continuation, that this would help my multi line SQL procedures.Again, I was mistaken. Perhaps I could write it all on one line. I'd be interested in knowing if there's a feature that I am not aware of. Well there are certainly many features which I'm not aware of, but I was referring to "long strings".
View 2 Replies
Jan 5, 2012
Module Module1
Public Structure structure1
Public TRANS() As structure2
End Structure
Public Structure structure2
Public X() As Integer
End Structure
End Module
View 17 Replies
Jan 5, 2010
I'm new to VB 2008 after having spent a long time with VB6, so I apologize if this is a stupid question. But I'd really like to have this straightened out.
Let's say I have a pretty large structure that has lots of properties.
Code:
Now say that I want an internal database with about 10 instances of this structure total, describing, say, 10 different products that a store sells. When these values are loaded from a database, they remain totally static. (However, they can be different each time a program loads)
Now say that I have a class. Each instance of this class is a type of that BaseProduct structure. Meaning, each instance of the class pertains to one of the 10 types of products that the store sells. However, this class has additional properties that pertain specifically to each instance, which are not static.
Code:
Now, the problem here is... If I have 200 different transactions, each one contains an instance of BaseProduct. BaseProduct is HUGE, and is largely redundant (only 10 types possible), so I think it's a little silly to include a whole copy of it with EVERY transaction. However, the Transaction class really needs information regarding the base product it pertains to. Is there a way to, instead of declaring a New BaseProduct in the Transaction class, to simply make one of the properties of the Transaction class a pointer to a BaseProduct variable?
In VB6, I would accomplish this by making a BaseProduct(10) array, and then giving each Transaction an ID number referring to an entry in that array. But in VB 2008, using class structure, this is impossible. I can't define the BaseProduct(10) array outside of a class in a namespace, and if I define it in the actual application's form, then the class loses modularity since it relies on the application that's using it.
View 11 Replies
Aug 29, 2009
I am trying to communicate with an external device and i am trying to send a byte array to the external device via sockets but i am always getting a response the message size is too small so i am not sure what i have done wrong. Between the data type there should be no alignment present and all numbers are represented in little endian format. The char array is not null terminated as mentioned in the protocol specifications.
I have to send data based on a struct that embeds 2 other struct. So here's my vb.net code for the struct used to convert to byte array and the sending part.
Public Structure MESSAGETYPE_OIP_Login
Dim Header() As COMMANDHEADER
Dim UserName() As PSTRING
[Code]....
View 2 Replies
Apr 14, 2012
I'm experiencing a problem with the following c-structure:
typedef struct tagTEXTUREPROP
{
DWORD dwSize;
[Code].....
The Marshal.SizeOf obviously calculates a size of 76 and it works with the DLL function, but it leaves me with some bad feelings.
View 1 Replies
Mar 6, 2010
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
Do I need make change on the call?
View 8 Replies
Aug 20, 2009
Hi. what is the difference of sleep function and pause function (using timer) between a loop.
View 12 Replies
Jan 26, 2010
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.
View 1 Replies
Apr 1, 2011
let say i have a function like this
' create filter
Dim colorFilter As New ColorFiltering()
' configure the filter
[code]....
View 9 Replies
Apr 3, 2012
how to create a structure in Visual Basic?r example:
Public SCARD_READERSTATE()
Dim szReader As String 'reader name
Dim pvUserData As Long 'user defined data
[code]....
I'm using Microsoft Visual Basic 2008.
View 2 Replies
Aug 8, 2009
I want to know that how we access a constant which is declared in a public structure, with an instance of that structure?
View 7 Replies
Jul 29, 2009
I want to pick specific elements from DateTime and assign them to variables: Year, Month, Day, Hour, Minute, and Second. In MSDN, I saw ways to assign it all, but not what I needed.
Can anyone one give a hint, or two?
View 4 Replies
Mar 13, 2010
Im triing to use structures.example
Public Structure Column
Dim ID As Integer
Dim Name String
Dim Birth As Date
End Structure
1) Is possible know how many element are in the structure?
2) is possible retrive the type of the data inside a structure? (Integer, String, Date)
3) is possible scan the element without use their name (by using an index as in the string) instead of use Column.ID=1 ? If the none of the questions are positive, what other stuff should i use that allow me to do that?
View 6 Replies
Mar 31, 2011
The General TreeView Structure, with the level indicated in the left.[code...]
Leaving the 0 and 1 levels, the other levels has to be treated as above. How to achieve this?
View 5 Replies