However it always returns 0. I've checked and the GetPartCost function executes and returns a non-zero number but the list item cost properties are never updated.The property is just a simple property,
Public Property Cost() As Double
Get
Return _Cost[code]....
If I set a breakpoint in the Set of the property, it never gets hit.
I have a custom list that inherits Generic.List and it has a method for deselecting all of the members named DeselectAll It has looked like this for a few weeks and has worked fine.
Public Sub DeselectAll() MyBase.ForEach(Function(p As Publipostable) p.ModeEnvoiChoisi = Nothing) End Sub
Today, it stopped working ?!? I reverted to an earlier version using delegates and that works fine...
Public Sub DeselectAll() MyBase.ForEach(AddressOf DeselectModeEnvoi) End Sub
[code]....
Edit: Stopped Working meaning it no longer sets the property p.ModeEnvoiChoisi to Nothing on each item in the list. The DeselectAll method gets called, but all the items retain their previous values...
Here's the code I have but I'm getting syntax issues:
CODE:
I'm just looking to call ReadAndPopulate method for each item in aList. I know I can do it the traditional "For each a in aList...Next" way but wanted to learn how to do it with delegates.
Is it possible to pass multiple arguments to a delegate method from a list(Of T).ForEach call?So, I'd like to pass a listbox object to the delegate routine below:
Sub test() Dim names As New List(Of String) names.Add("Bruce") names.Add("Alfred")
I've been trying to get the update method to work on a DataGridView for the past 2 days and I just can't get it to happen!I'm using a "Save Button" to invoke the update and no errors are thrown but the table is not updated when the save button is pressed.
Private Sub Main_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load With NodesDataGridView.ColumnHeadersDefaultCellStyle .Alignment = DataGridViewContentAlignment.MiddleCenter
I load a list from a database like the example below. The class has more properties that the database table holds so when I load the list from the DB, there are Null values for certain properties of each item in the list. When I try List = List.Distinct.ToList, it never works (when null values are present).
I have searched high and low for documentation on how to use this feature. While the loop I could write would be simple and take no time, I really would like to learn how to use this. Basically I have a class, say, Widget, with a Save() sub that returns nothing. So:
Dim w as New Widget() w.Save()
basically saves the widget. Now let's say I have a generic collection List(Of Widget) name widgetList(Of Widget) and I want to run a Save() on each item in that list. It says I can do a
widgetList.ForEach([enter Action(Of T) here])
....but how in the F does this work??? There is no documentation anywhere on the intrablags.
I have a textbox which will accept a user input for a email address or phone number.I want to using a new thread do a search for various results and populate a listbox.I know i need to do this in another thread so my main form will still operate but how can I do this? I've never used threads before and I know it's tricky to get the values from a textbox and also update a list box on another thread.
When i parse some html and get the fields i need using regex, the first 4 fields returned are fields i don't need, so essentially i need all fields returned after the 4th one.
vb.net '// First piece of data we want... Dim stringID As New Regex("(?<=><optionvalue="").*?(?="">)", _ RegexOptions.IgnoreCase Or RegexOptions.Singleline) Dim stringsMatched As MatchCollection = stringID.Matches(stringClean)
[CODE]...
Is there a way i can blank out the first 4 fields returned?
I'm trying to code a class of RandomNumber. One of the class methods needs to populate a "List (Of RandomNumber)" ... which was passed as a parameter to the method ... with 10 random numbers between 1 and 50. DEAD SIMPLE :)
I have an Excel worksheet with a Source Cell and a Target Cell.Via GDI API functions, I draw a temporary gradient fill over the source cell which happens to be cell "D6"then, I make a transparent copy of the temp gradient fill drawn over the source cell and place the copy (ie the transparent gradient fill) over the target cell which happens to be cell "D9".
I want to fetch data from a database table modify it and update it without being dependent on the database provider and the database structure, because it will be part of a library.My first attempt was as follows:
'factory defined somewhere else as DbProviderFactory 'connection is a working DbConnection Dim selectcmd As DbCommand = connection.CreateCommand()[code]....
it did not work. After further investigation I figured out that the Commands the CommandBuilder generated were useless, because it inserted ? instead of @param1 for all Parameters. It generated something like INSERT INTO tbl1 (field1, field2, field3) VALUES (?, ?, ?) for the InsertCommand.I would really like to use the CommandBuilder, because it is simple and I don't have something complicated like JOINS.
Dim clcexists = (From p In dbContext.Signatures _ Where p.StudentID = people_id _ And p.ContractType = "clc" _ Order By p.ID Descending _ Select p)
Later I check whether any rows exist in clcexists using IsNothing like so:
If IsNothing(clcexists) Then ' If no CLC is on file. clcfirst = Date.Now.Subtract(year) clcdate = clcfirst
[Code]....
But IsNothing() is not functioning like I expect. There is no row in the results table, but it is still acting as if there is and going to the Else clause.
I am running Windows 7 pro and using Visual Basic 2010 express.I have written a small program to switch on a USB relay which is controled by a serial port.I have debuged the program and it appears to work correctly. I have published the program and if I start it from thr run menu / desktop shortcut / or through explorer it works as expected.
However I have tried to run it by the Task Scheduler and then it fails to run as expected. I have a small section of code that checks to see if the serial port is present if not I have used messagebox.show to ask for the relay to be pluged in. In every case other than when running through the Task Scheduler the messagebox works with the Task schedulerit doesn't show the messagebox and the program hangs I have included the code I have used.
Dim retry As Boolean = False Dim data() As Byte = {255, 1, 1} Do Until retry
[URL]. I have a Multi-Line textbox with several accounts in it. They are in email@email.comassword format on separate lines. All the code is right, but it goes really weird and loops like 3 times before logging in. Eventually logging into the last account on the Textbox instead of the first. It should just login to the first account...Logout....Login to the second account...Logout and continue the process.
If you want to test it, just put a web browser and a textbox1 multiline box, a button and enter a few working hotmail accounts and you'll see. Check line 17 Looks like a lot of code, but line 17 is the only bit that needs to be looked at. The rest is just junk/non-relevant to this problem. It separates the accounts perfectly and stuff, but just wont login in the right order.
I have declared a String variable(PC) for use within another String variable(currentQuery) to form a SQL statement to pass to my SQLDataAdapter variable.
I'm performing this action to change the string variable(PC) for the different onClick events I have.
It seems i can change this variable (PC) within my onClick event handlers and the 'PC' variable will change when I apply it to a testing Text Box 'testTextBox' but not for the currentQuery variable.
Do i need to perform this action as a function or am i missing something obvious - code below - I don't want to spend time writing a function to return a string value for my SQL statement if i can just tweek something in my code (below).
Partial Public Class IVMain Inherits System.Web.UI.Page Dim DBConn As New SqlConnection("Data Source=hnaServer;Initial Catalog=Hnastatus;User ID=Test;Password=test")
I have a form with a split panel. In the one split are a group of buttons which I want to programmatically change the color of the last pressed button.The following loop seems to run correctly and set the colors correctly but the form doesn't represent that. Once the loop is completed and I recheck the button colors, they revert to previous state.[code]I can get the desired effect by doing the below code but seems less elegant and would obviously require updates as buttons would be added or removed.[code]
I was toying around with some of the linq samples that come with LINQPad. In the "C# 3.0 in a Nutshell" folder, under Chater 9 - Grouping, there is a sample query called "Grouping by Multiple Keys". It contains the following query:
from n in new[] { "Tom", "Dick", "Harry", "Mary", "Jay" }.AsQueryable() group n by new {
Dim x = GetType(List(Of )) 'valid statement Dim list As New List(Of String)
Now I want to see if list is a List(Of T) variable: Dim isList = TypeOf list Is List(Of ) On the last line I get a compile error: "Type Expected". Is there any cheap-performance TypeOf operator alternative for generics?
Full Program: Option Strict On : Option Explicit On Module Module1
[Code]...
After I ran it, I had a file a.txt in my debug folder but the size is 0 bytes (and when i open it is empty of course) Shouldn't the output had "asd" in it ?
The idea with this form is to add the futures which is calculated when the button is pushed but I need the list to update every time and show the values each time to which the previous value is added to the new calculation, e.g. of what it should look like in listbox:
Year 1: $1,290.93 Year 2: $2,724.32 Year 3: $4,350.76 etc....
I have been working on this a while and I am at a standstill, I was given a function to clear the form everytime it calculates but I don't know how to implement it, I am new to VB. Here is what I have so far:
Public Class frmFutureValue Private Sub btnCalculate_Click(ByVal sender As System.Object, _ ByVal e As System.EventArgs) Handles btnCalculate.Click
In a public module (codefile) I defined a data structure called db_connection,then declared a variable of that type like so: Public db_con as db_connection I pass db_con to a sub. I expected the db_con structure to be populated with values after the call to the sub. It does not.This is something I have done for years in vb6.What might have changed to prevent this from working?
Public Sub UpdateStaff(ByVal sr As StaffRecord) Dim oldSr As StaffRecord Dim q = From staff In db.StaffRecords Where staff.Employee_Number = sr.Employee_Number Select staff oldSr = q.First oldSr.Address_Line1 = sr.Address_Line1
[Code]...
The helper function I have written seems to do everything I want apart from update the db. Stepping through the code, the oldSr is updated by the new sr parameter but no update on submit changes.
I'm not sure why the following code is not working as intended:
CODE:
Where litMessage is the name of the literal control and messageBody is the name of the string variable.
My intention is to output a string onto a web page and to replace the line breaks with a br tag so that it can be displayed on the page correctly. However, nothing is replaced. When viewing the page source, it looks like the line breaks still exist in the string. Similarly, when displaying the string via MsgBox, it displays normally as well. I have also tried wrapping the output with the pre tag and it displays the line breaks properly as well.
The string was originally entered by a user through the use of an asp:Textbox and saved into a MSSQL database. It's retrieved and displayed on another webpage using an asp:Literal control. The only thing that happens to the string before it is submitted is that it is trimmed (i.e. textbox.Text.Trim()).
Perhaps there is something I did not consider?
Edit #1: Due to time constraints, I've decided to just wrap the text with the pre tag. It's an acceptable work around as it preserves the line breaks. Unfortunately, it doesn't explain why the code didn't work in the first place. In the meantime, I'll just leave the question unanswered until I find a proper answer.
Edit #2: Solution found and answered below. UpdatePanel tag added to the question for future reference.