VS 2008 FilePut And FileGet From And Into Structure Variables?
Mar 22, 2010
In VB6 I can open a file for binary read/write and then use Put and Get to write Type structures straight to disk and subsequently retrieve that information straight from disk and right back into the structure. The syntax is pretty straightforward, and it works fast and without flaw.
In VB.NET I've tried the same thing. But in absence of a "Type" variable, I've tried using Structure ... End Structure, which should basically be the same thing.The problem is, though we can write the structure to disk:
Dim FileNo as Integer
Dim FilePath as String
FileNo = FreeFile()
FilePath = "C:TestFile.dat"
[code]....
I need to create an extremely large and complex structure that will be used in a whole slough of ways, and when all work is done I need to write that structure straight to disk using a binary mode. When that information is needed again, I need to be able to get it back just the way it was saved and continue working with it again. The basic outline of the concept is illustrated above, which works--as I mentioned above--flawlessly in VB6.
Im trying to load a price of an item from a prices file (Items). The variable (ItemName) is taken from a listox populated from the file on another form. And (Item) is the structure which i saved the prices information for into (Items).
What im trying to do is take the string from the listbox and change the textbox (txtCurrentPrice) text into the price for the highlighted item, which is also the name of the (txtItem) textbox.
However i cant find a way to reference the Item.(ItemName) to get the correct price from within the file, as ItemName isnt a member of the Items structure Item instance.
ChangeItemForm Private Sub ChangeItemForm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
[Code]....
ItemName holds the name of one of the variables saved in the structure. So say if ItemName was holding "IridescentRoll" As its string I would be trying to find Item.IridescentRoll, which would show me the price of IridescentRoll which im trying to put into the textbox. and As Item.IridescentRoll = 3.35 it would display 3.35 in the textbox.
As you have probably guessed, the Item.ItemName doesnt work ('ItemName is not a member of...'
Is there any way to write this without having to create a new record for each item? As that would take a while, and im not sure i have the time x.X
I recently upgraded an application that creates several report files, that are read by an older VB6 application that i cannot upgrade. I've gotten everything working (faster than i expected) except the new FilePut. I'm saving the ubound of an array, which is a UDT, Then saving the array itself(which again, is a UDT)No matter what I do, the file is about 7 b larger, and doesnt want to read in at all in VB6. For example, I put an 32 bit integer into the file, say 4000, VB6 reads it as 3948395 or so, it seems its padding the file at the beginning or something.
And Yes, i've tried microsofts ArrayIsDynamic function, but it seems to have made no difference at all.
Code: Public Structure StrFolder Public isActive As Boolean Public NameFolder As String[code]....
I would like to retrieve and print each variable name within a given structure (not its value). For example:
StrFolder(0).Name should print "isActive" StrFolder(1).Name should print "NameFolder" StrFolder(2).Name should print "URLIDNumber" StrFolder(3).Name should print "DateOfFolder" etc..
I would also like to know each type of an item within a structure. For example:
StrFolder(0).Type should print "Boolean" StrFolder(1).Type should print "String" StrFolder(2).Type should print "Integer" StrFolder(3).Type should print "String" etc..
I have created a structure with some variables that I'm trying to update during the course of a sub routine but they are not updating, when I cycle though them at the end all the variables are still set to 0.
Imports System.Data Imports System.Collections Structure Team
I found out that you cannot set the array size for a structure when you are making it, i.e
[Code]...
I have to fix this by making a variable with type made by Structure bullet and then redimming it, i.e
[Code]...
This means for every variable with the bullet type i create i have to redim. Is there a way i can set the size of .mesh with .capacity for every single variable created with the bullet type automatically?
I'm using a Listview in VirtualMode, so I can 'add' a lot of files almost instantly. A Listview in VirtualMode does not allow sorting, so I need to sort the data myself. The data is stored as a List of Structure (it's faster to load than a List of ListViewItem). The code below works fine, but I need to sort based on multiple variables in the Structure. Code:
I've been using things like FileOpen, and FilePut for a long time in VB.NET, and it's never presented any problems. However in my latest project I'm using CodeDom to compile at runtime, as you know FileOpen, and things like that are the old VB6 methods, such as MsgBox("Msg"), and these don't work. So I need to know how to do this using only the newer VB.NET code.
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">
I have a class that pulls the ID3 information from an MP3 file. This information is at the very end of the file in plain ASCII. The original author is using FileGet to retrieve just the last 127 characters of each mp3 file. The issue is that this information is put into strings declared like this...
Public strTag As New String(" ", 3) Public strTitle As New String(" ", 30) Public strArtist As New String(" ", 30)
[CODE]...
This part all works fine. But I'm trying to code a property that returns a string like this...
return strTitle & " - " & strArtist
But for some odd reason it is being very strict about the length of the returned string. It usually just returns the strTitle, and not the " - " or strArtist, and if I switch the positions, it will just return strArtist. So obviously both Strings have information in them.
I'm an intermediate programmer, but just breaking into VB.NET. I'm not sure what the New String(" ",30) part does, but it is definitely interfering with the string concatenation that I'm trying to return. Anyone ever had a similar issue?
I've tried String.Copy, String.Concat, etc. I've also tried doing ReadtoEnd(), but it takes forever for just 10 mp3 files, so I can't imagine how long it would take with a whole library. The only thing that slightly works is if I do... return strTitle.SubString(0,5) & " - " & strArtist.SubString(0,5)
But like I said, coincidentally it will only return around 30 characters.
I must search a binary string for a pattern. This worked fine in VB6 using Get to read a file into a string and using InStr to search for the pattern. The conversion from VB6 to VB.NET changed Get to FileGet and warned of new behavior, but I don't see anything in the FileGet documentation about not being able to read 0 value bytes.
I don't mind at all changing to a new method, but ultimately I must get the data into a string rather than an array.
Last year (2010) I came across a FANTASTIC command that allowed me to take a string of variables with a common delimiter and break it all back out into separate variables (possibly an array) with one statement.
[Code]...
As long as the delimiter was a unique specifiable character, this one-statement command could break it out into elements. my memory and point me in the right direction.
In VB.NET I would like to create a complicated data structure with multiple types of data stored in an array like format (see below). I am trying to create a data structure that would look something like this: [Name; xLoc; yLoc; zLoc; [Jagged Array]] Note: Name needs to be dimensioned as a string, xLoc and so forth as integers. The Jagged Array would look like this:
Module Module1 Public Structure structure1 Public TRANS() As structure2 End Structure Public Structure structure2 Public X() As Integer End Structure End Module
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.
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
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.
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?
writing an XML-formatted string so that I may later encrypt it.If I create an XMLDocument,it will insert its formatting tag <?xml version="1.0" encoding="Windows-1252"?> and I need to avoid this.I'm not very familiar with streams, or how to output an XMLWriter to one.
I am using Visual Basic .NET 2008. I have a module in my project and couple of windows forms. Now in my module I wrote -
Structure Transport Dim Veh as Vehicle ' pointing to enum below Dim GoAhead as boolean End Structure
[code]....
What I want is that another form should be able to call my sub Select (declared as public) and pass enum data declared in Transport structure. VB allows me to do that if my sub is private but not if my sub is public. To overcome this issue one solution is to declare the enum in the form class itself. But for this I will have to do it in each form.