|
on click:
<br />
if me.listbox1.items.contains(me.textbox1.text) then<br />
me.textbox2.text = me.textbox1.text 'or whatever you want it to do<br />
else<br />
me.textbox2.text = me.listbox1.findstring(me.textbox1.text) 'or whatever you want it to do<br />
end if
this will check for an exact match, then if that is unavailable, will return the closest match. i just used textbox1 as the input and textbox2 as the output.
Posted by The ANZAC
|
|
|
|
|
Anzac,
Thank for your your response. I tried this code and it appears to work well. Quick question for you (since I am still fairly new). When it finds the closest match I noticed that it will output the position/index of the closest match instead of the number in that position.
For example, if the closest match is 9th down from the top in the list, the code will output "8" for the position of the number in the list instead of the actual number in the list.
Thanks!!
Mike
|
|
|
|
|
it will give 8 instead of 9 because in vb.net all items that are indexed start at zero. So the first item is zero the second is 1 etc. Your index will always be from 0 to (no of items - 1).
if you want it to output the actual value then instead of:
me.textbox2.text = me.listbox1.findstring(me.textbox1.text)
use:
me.textbox2.text = me.listbox1.items.item(me.listbox1.findstring(me.textbox1.text))
Posted by The ANZAC
|
|
|
|
|
|
Hello,
Thank you for your response. I agree that string edit distance seems to be what I need. The only problem is that all the examples I saw show how to compare one string to another but not one string to a whole list and pick out the best.
Do you have any ideas on that?
Thanks,
Mike
|
|
|
|
|
well, the brute force approach says that you do the calculation against each of the strings in the list and pick the string with the lowest edit distance
Im sure there is a way of optimizing this approach, I just cant recall it
'g'
|
|
|
|
|
That's what findstring does. it's a built in function for the listbox that searches the list, comparing it to a given string and returning the closest match. There really should be a need for complex string algorithms.
Posted by The ANZAC
|
|
|
|
|
These 13 textboxes are in a group box. When I click the calc button I need to add the total of all of these textboxes. I just need a way to do it with out typing soooo much code. Otherwise this is how I would do it...
If isnumeric(textbox1.text) and isnumeric(textbox2.text) 'and so on and so on then<br />
label18.text = "$" & int(textbox1.text) + int(textbox2.text) 'and so on and so on<br />
end if
however i do not wish to type 13 textbox(isnumeric) and 13 textbox(int)'s. There has got to be an easier way to do this with less code. Thank you in advance!!!
|
|
|
|
|
You can do it by reading the values of each TextBox in your GroupBox, like so:
Dim AllText As Integer
Dim Box As TextBox
For Each Box In GroupBox1.Controls
AllText += Box.Text
Next
Trinity: Neo... nobody has ever done this before.
Neo: That's why it's going to work.
|
|
|
|
|
Does anyone have a project that they have done that demonstrates how to use the GraphicsServer.GSNET.Charting.GSNetWebChart.
Thanks
|
|
|
|
|
I have been working on converting an old application from VB 6.0 to VB.Net. I have used the VB.Net 2005 conversion tool, but it still requires more editing on my part to have it function properly. My problem deals with taking a .dat file and inputing the data into an array TestRecord(2) using the FileGet function.
The VB 6.0 code works fine as bellow:
FileName$ = "c:\Impact-E\TestFiles\" & Text1.Text & ".dat"
Open FileName$ For Random As #3 Len = Len(TestRecord(1))
Get #3, I, TestRecord(2)
But after I used VB.Net 2005 conversion tool and rewrote the code it still does not work.
FileName = "c:\Impact-E\TestFiles\" & Text1.Text & ".dat"
FileOpen(3, FileName, OpenMode.Random, , , Len(TestRecord(1)))
FileGet(3, TestRecord(2), I) 'Error occurs on this line
The VB.Net code will open and begins to read the data, but then gives me an error #5. Saying its unable to read beyond the end of the stream.
Any help at all would be excellent
|
|
|
|
|
How have you defined TestRecord?
My guess is that the definition of TextRecord has become larger in the conversion. If you for example depend on the size of an Integer, it is four bytes in VB.NET while it was only two bytes in VB 6. The equivalent of a VB 6 Integer in VB.NET is Int16.
---
Year happy = new Year(2007);
|
|
|
|
|
Test Record is defined as a structure. I must have done something while converting the code because the TestRecord() has become smaller through the conversion.
Test Record Size:
VB 6.0 -> Len(TestRecord(1)) the size was 8378
VB.Net -> Len(TestRecord(1)) now the size is 8370
and using FileLen(FileName), I found that my file size is 8372. So i'm overloading the file. Do you think I should change the TestRecord file size, or change the code that creates the file?
|
|
|
|
|
I have an application that allows editing of test patterns for microcontrollers. The test patterns are 8 byte blocks, I store them in an array so I can manipulate them, then convert and save them to a file.
My most recent pattern is several million bytes long, something like
FFA01211
FFA01211
FFA01311
FFA11311
FFA11111
FFA01111
FFA11311
FFA01111
FFA11311
...
I run a portion of the conversion as follows:
i = ubound(myArrayOfData)
for j = 0 to i
ResultData = ResultData & myArrayOfData(j)
next
The above portion will take days to run
The question is this. Is there a better way to do this?
My resultData needs to be a long string that is comprised of all the elements in the array similar to teh following:
FFA01211FFA01211FFA01311FFA11311FFA11111FFA01111FFA11311FFA01111FFA11311....
This is VB6
Thanks
|
|
|
|
|
ResultDate = Join(myArrayOfData,"")
|
|
|
|
|
Thanks, but for simplicity sake I just used an array in my example, my array is actually a structured array
data(i).HexVal
|
|
|
|
|
Well it seemed "too" simple
You could write a class that would control the array. While you are populating the array you are also creating the string. Any manipulation of the array would change the string as well ex: If every occurrance of the HexVal 8 characters in length then if you change the value of sub 20 then replace the value of the string at position 160 at the same time...
Data(20).HexVal = "FA033A39"
Mid(ResultData,160,8) = "FA033A39"
Just an idea...
|
|
|
|
|
Thanks for the feedbak, I guess I could do that but the manipulation of the string can get kind of messy as I do all kinds of weird stuff with it (looking for repeated patterns, deleting chunks, inserting repeat lines and such).
Figure there is a way to copy this array to an simple one fairly quickly?, then use join?
|
|
|
|
|
if you wanted to copy the entire structure to a string, then you could use the copymemory api and the function strptr, but if you want only one field of the structure...then from what I can tell, your original for/next loop or my class idea is your best bet...
|
|
|
|
|
First just to make sure has 'j' been declared? I know in vb.net if you don't declare your variable for the loop you get a huge performance hit.
But the real reason it takes forever is explained here. http://support.microsoft.com/kb/170964[^] I believe code to help fix the problem is provided. I dealt with this issue a while ago and someone pointed me to a different article that explained the problem and provided a class. The class worked great and I still have it on my computer although I don't remember the address of the original article. If you don't like the solution microsoft gives maybe the class I have will help. Let me know if you want it and I'll send it to you if you'd like, or I suppose I could just post the code here as it's not that long. I really wish I could find the original article online.
|
|
|
|
|
|
Yes, everything declared, thanks for the info, this is eactly what I was looking for. I ama happy customre!
|
|
|
|
|
I am trying to build GrirdViews and ObjectDatsources dynamically as it could be any number.
I have built the grid no problems but i cannot work how to build the objectdataource dynamically.
Grid = New ReportingGrid
DataSource = New ObjectDataSource
DataSource.ID = "ODS" & Counter
DataSource.SelectMethod = "ReturnDataTable"
DataSource.TypeName = "Eurofins.EOLDotNET.SummaryReport"
DataSource.Select()
Grid.DataSource = DataSource.ID.ToString
Grid.DataBind()
This however creates a new version of the SummaryReport class so there is no data to retrieve.
Basically I have the data in a dataset that is global to the class and I wan to create a ObjectDataSource and assign it to this dataset.
Any ideas would be very welcome.
Sorry bout this post but I'm quite new to these sort of things.
|
|
|
|
|
In VB2005, I've done an application and a library that is used within the application. Both of them call a function that is placed in the library and that permits to write a message in the same logfile.
I'd like to add the caller's name in the log file so each message in the log would have the source that has written the line. For example:
appname.exe: error msg ...
libname.dll: error msg ...
Is there any way to retrieve the caller's name from within the function?
Thanks in advance,
Marc Soleda
... she said you are the perfect stranger she said baby let's keep it like this... Dire Straits
|
|
|
|
|
Try Application.ProductName
|
|
|
|