Search Results

Search found 4472 results on 179 pages for 'vb'.

Page 113/179 | < Previous Page | 109 110 111 112 113 114 115 116 117 118 119 120  | Next Page >

  • Null reference but it's not?

    - by Clint Davis
    This is related to my previous question but it is a different problem. I have two classes: Server and Database. Public Class Server Private _name As String Public Property Name() As String Get Return _name End Get Set(ByVal value As String) _name = value End Set End Property Private _databases As List(Of Database) Public Property Databases() As List(Of Database) Get Return _databases End Get Set(ByVal value As List(Of Database)) _databases = value End Set End Property Public Sub LoadTables() Dim db As New Database(Me) db.Name = "test" Databases.Add(db) End Sub End Class Public Class Database Private _server As Server Private _name As String Public Property Name() As String Get Return _name End Get Set(ByVal value As String) _name = value End Set End Property Public Property Server() As Server Get Return _server End Get Set(ByVal value As Server) _server = value End Set End Property Public Sub New(ByVal ser As Server) Server = ser End Sub End Class Fairly simple. I use like this: Dim s As New Server s.Name = "Test" s.LoadTables() The problem is in the LoadTables in the Server class. When it hits Databases.Add(db) it gives me a NullReference error (Object reference not set). I don't understand how it is getting that, all the objects are set. Any ideas? Thanks.

    Read the article

  • Sorting Custom Objects with Parameter in VB.Net/C#

    - by Jeffrey Kern
    Let's say I have a custom object of Foo Is there anyway I can sort through a list of these objects, like list<of foo>.sort() and also be able to sort this list with a passable parameter. which will influence the sort? list<of foo>.sort(pValue) I'm guessing I'll need to define two separate sorts, but I am not sure. Thanks!

    Read the article

  • String / DateTime Conversion problem (asp.net vb)

    - by Phil
    I have this code: Dim birthdaystring As String = MonthBirth.SelectedValue.ToString & "/" & DayBirth.SelectedValue.ToString & "/" & YearBirth.SelectedValue.ToString Dim birthday As DateTime = Convert.ToDateTime(birthdaystring) Which produces errors (String was not recognized as a valid DateTime.) The string was "01/31/1963". Any assistance would be appreciated. Thanks.

    Read the article

  • Making A Dynaically Created Excel Report Downloadable

    - by Nick LaMarca
    I have 2 blocks of code, if someone could help me put them together I would get the functionality I am looking for. The first block of code downloads a gridview to excel using the download dialog I am looking for: Public Overloads Overrides Sub VerifyRenderingInServerForm(ByVal control As Control) ' Verifies that the control is rendered End Sub Private Sub ExportToExcel(ByVal filename As String, ByVal gv As GridView, ByVal numOfCol As Integer) Response.Clear() Response.Buffer = True Response.AddHeader("content-disposition", String.Format("attachment; filename={0}", filename)) Response.Charset = "" Response.ContentType = "application/vnd.ms-excel" Dim sw As New StringWriter() Dim hw As New HtmlTextWriter(sw) gv.AllowPaging = False gv.DataBind() 'Change the Header Row back to white color gv.HeaderRow.Style.Add("background-color", "#FFFFFF") For i As Integer = 0 To numOfCol - 1 gv.HeaderRow.Cells(i).Style.Add("background-color", "blue") gv.HeaderRow.Cells(i).Style.Add("color", "#FFFFFF") Next For i As Integer = 0 To gv.Rows.Count - 1 Dim row As GridViewRow = gv.Rows(i) 'Change Color back to white row.BackColor = System.Drawing.Color.White For j As Integer = 0 To numOfCol - 1 row.Cells(j).Style.Add("text-align", "center") Next 'Apply text style to each Row row.Attributes.Add("class", "textmode") 'Apply style to Individual Cells of Alternating Row If i Mod 2 <> 0 Then For j As Integer = 0 To numOfCol - 1 row.Cells(j).Style.Add("background-color", "#CCFFFF") row.Cells(j).Style.Add("text-align", "center") '#C2D69B 'row.Cells(j).Style.Add("font-size", "12pt") Next End If Next gv.RenderControl(hw) 'style to format numbers to string Dim style As String = "<style> .textmode { mso-number-format:\@; } </style>" Response.Write(style) Response.Output.Write(sw.ToString()) Response.Flush() Response.End() End Sub The second block of code is a sample report I am wish to be downloaded. So instead of downloading a gridview I want this function to accept a worksheet object.

    Read the article

  • How can i read back an object stored in a session?

    - by strakastroukas
    First of all, here comes the load part. Structure MainStruct Dim Ans1 As String Dim Ans2 As String End Structure Dim Build As New List(Of MainStruct) ... ... ... Session("MyData") = Build The question is how can i read back the contents of the list, stored in the Session? I mean something like... Build = Session("MyData").Ans1

    Read the article

  • Visual Basic: Newbie questions.

    - by Omega
    Hello there. I am starting to learn visual basic. So far, it is quite simple and easy to use. I am liking it! Anyway, I want to make applications a little bit more complex. So far I have done very silly things. I would appreciate if you could help me with these: How do I open a new window (form)? Maybe I click a button on my main form and another form pops up. How do I "deactivate" the main form while the new form is running? (if I try to click the main form, an error sound plays) So my second form has a text field and a "OK" button. If I click it, the second form closes activating the main form again. I want to "pass" the text in the text field from the second form to the first one. How do I do that? Thank you, I am enjoying this new programming environment (didn't use Visual Studio much before)

    Read the article

  • Crossthread exception and invokerequired solution doesn't change my control value

    - by Pilouk
    EDIT Solution : Here i'm setting my byref value in each object then i'm running a backgroundworker Private Sub TelechargeFichier() Dim DocManquant As Boolean = False Dim docName As String = "" Dim lg As String = "" Dim telechargementFini As Boolean = False lblMessage.Text = EasyDealChangeLanguage.Instance.GetStringFromResourceName("1478") prgBar.Maximum = m_listeFichiers.Count For i As Integer = 0 To m_listeFichiers.Count - 1 m_listeFichiers(i).Set_ByRefLabel(lblMessage) m_listeFichiers(i).Set_ByRefPrgbar(prgBar) m_listeThreads.Add(New Thread(AddressOf m_listeFichiers(i).DownloadMe)) Next m_bgWorker = New BackgroundWorker m_bgWorker.WorkerReportsProgress = True AddHandler m_bgWorker.DoWork, AddressOf DownloadFiles m_bgWorker.RunWorkerAsync() ''Completed 'lblMessage.Text = EasyDealChangeLanguage.Instance.GetStringFromResourceName("1383") 'Me.DialogResult = System.Windows.Forms.DialogResult.OK End Sub Here is my downloadFiles function : Note that each start will do the downloadMe function see below too Private Sub DownloadFiles(sender As Object, e As DoWorkEventArgs) For i As Integer = 0 To m_listeThreads.Count - 1 m_listeThreads(i).Start() Next For i As Integer = 0 To m_listeThreads.Count - 1 m_listeThreads(i).Join() Next End Sub I have multiple thread that each will download a ftp file. I would like that each file that have been completed will set a value to a progress bar and a label from my UI thread. For some reason invokerequired never change to false. Here is my little function that start all the thread Private Sub TelechargeFichier() Dim DocManquant As Boolean = False Dim docName As String = "" Dim lg As String = "" Dim telechargementFini As Boolean = False lblMessage.Text = EasyDealChangeLanguage.Instance.GetStringFromResourceName("1478") prgBar.Maximum = m_listeFichiers.Count For i As Integer = 0 To m_listeFichiers.Count - 1 m_listeFichiers(i).Set_ByRefLabel(lblMessage) m_listeFichiers(i).Set_ByRefPrgbar(prgBar) m_listeThreads.Add(New Thread(AddressOf m_listeFichiers(i).DownloadMe)) Next For i As Integer = 0 To m_listeThreads.Count - 1 m_listeThreads(i).Start() Next For i As Integer = 0 To m_listeThreads.Count - 1 m_listeThreads(i).Join() Next 'Completed lblMessage.Text = EasyDealChangeLanguage.Instance.GetStringFromResourceName("1383") Me.DialogResult = System.Windows.Forms.DialogResult.OK End Sub Here my property that hold the Byref control from the UI thread. This is in my object which content the addressof function that will download the file (DownloadMe) Public Sub Set_ByRefPrgbar(ByRef prgbar As ProgressBar) m_prgBar = prgbar End Sub Public Sub Set_ByRefLabel(ByRef lbl As EasyDeal.Controls.EasyDealLabel3D) m_lblMessage = lbl End Sub Here is the download function : Public Sub DownloadMe() Dim ftpReq As FtpWebRequest Dim ftpResp As FtpWebResponse = Nothing Dim streamInput As Stream Dim fileStreamOutput As FileStream Try ftpReq = CType(WebRequest.Create(EasyDeal.Controls.Common.FTP_CONNECTION & m_downloadFtpPath & m_filename), FtpWebRequest) ftpReq.Credentials = New NetworkCredential(FTP_USER, FTP_PASS) ftpReq.Method = WebRequestMethods.Ftp.DownloadFile ftpResp = ftpReq.GetResponse streamInput = ftpResp.GetResponseStream() fileStreamOutput = New FileStream(m_outputPath, FileMode.Create, FileAccess.ReadWrite) ReadWriteStream(streamInput, fileStreamOutput) Catch ex As Exception 'Au pire la fichier sera pas downloader Finally If ftpResp IsNot Nothing Then ftpResp.Close() End If Dim nomFichier As String = m_displaynameEN If EasyDealChangeLanguage.GetCurrentLanguageTypes = EasyDealChangeLanguage.EnumLanguageType.Francais Then nomFichier = m_displaynameFR End If If m_lblMessage IsNot Nothing Then EasyDealCommon.TH_SetControlText(m_lblMessage, String.Format(EasyDealChangeLanguage.Instance.GetStringFromResourceName("1479"), nomFichier)) End If If m_prgBar IsNot Nothing Then EasyDealCommon.TH_SetPrgValue(m_prgBar, 1) End If End Try End Sub Here is the crossthread invoke solution function : Public Sub TH_SetControlText(ByVal ctl As Control, ByVal text As String) If ctl.InvokeRequired Then ctl.BeginInvoke(New Action(Of Control, String)(AddressOf TH_SetControlText), ctl, text) Else ctl.Text = text End If End Sub Public Sub TH_SetPrgValue(ByVal prg As ProgressBar, ByVal value As Integer) If prg.InvokeRequired Then prg.BeginInvoke(New Action(Of ProgressBar, Integer)(AddressOf TH_SetPrgValue), prg, value) Else prg.Value += value End If End Sub The problem is the invokerequired never get to false it actually goes in to beginInvoke but never end in the Else section to set the value.

    Read the article

  • Why is textbox.focus throwing the lostfocus event?

    - by cost
    I've seen a few similar questions on SO but nothing that seems to actually address the issue. Here's a simplified version of the function. Private Sub Check_Quantity(sender As System.Object, e As System.Windows.RoutedEventArgs) _ Handles textbox_quantity.LostFocus Dim worked As Boolean = Integer.TryParse(textbox_quantity.Text, quantity) If Not worked Then MsgBox("Enter a valid number for the quantity") textbox_quantity.Focus() textbox_quantity.SelectAll() quantity = 0 End If End Sub It's important to note that this is WPF. What I want to do is very simple. When someone finishes with the textbox the program checks that what they entered is a number. If it does it sticks this in an integer. If not, it tells them to fix it and keeps the focus on the textbox. The issue is a few things, but what it comes down to is this function runs in an infinite loop. This same function works fine in WinForms, but not in WPF. On some other questions people have said that the messagebox appearing causes focus to be lost, but in testing this isn't true. It still loops regardless of if the messagebox is called or not. The problem is the call to textbox_quantity.Focus(). Without that it works fine. Regardless of whether it's there or not though, focus is not set to the textbox, though textbox_quantity.Focus() still returns a value of true. Any thought of what's going on and maybe how I could fix it?

    Read the article

  • Get information from a higher class?

    - by Clint Davis
    I don't know really how to word the question so please bear with me... I have 3 classes: Server, Database, and Table. Each class has a "Name" property. How I want it to work is that each server can have multiple databases and each database can have multiple tables. So in the Server class I have this property. Private _databases As List(Of Database) Public Property Databases() As List(Of Database) Get Return _databases End Get Set(ByVal value As List(Of Database)) _databases = value End Set End Property And I have something similar in the Database class for the tables. This works fine now because I can do something like this to get all the databases in the server. For Each db In s.Databases 's being the server object Debug.Print(db.Name) Next I would like to expand these classes. I want the server class to handle all the connection information and I would like the other classes to use the server class's connection information in them. For example, I setup a server class and set the connection string to the server. Then I want the database class to use serverclass.connectionstring property to connect to the server and get a list of all the databases. But I want to keep that code in the database class. How can I do this? I've attached some code of what I want to do. Public Class Server Private _name As String Public Property Name() As String Get Return _name End Get Set(ByVal value As String) _name = value End Set End Property Private _databases As List(Of Database) Public Property Databases() As List(Of Database) Get Return _databases End Get Set(ByVal value As List(Of Database)) _databases = value End Set End Property End Class '-----New class Public Class Database Private _name As String Public Property Name() As String Get Return _name End Get Set(ByVal value As String) _name = value End Set End Property Private _tables As List(Of Table) Public Property Tables() As List(Of Table) Get Return _tables End Get Set(ByVal value As List(Of Table)) _tables = value End Set End Property 'This is where I need help! Private Sub LoadTables () dim connectionstring as string = server.connectionstring 'Possible? 'Do database stuff End Class Thanks for reading!

    Read the article

  • Inheriting a Base Form but Paste/Cut Commands Not Captured

    - by ohu812
    I created a base form that has a specific size and an icon as a base for all forms created in my project (to be consistent in looks). The problem is, for some reason if I add a Text box to the Child form, I can no longer execute shortcuts like Copy (CTRL+C) etc into the Textbox. What should I do to handle this OTHER THAN writing code to capture those on the KeyUp control? This is also the case for RichTextBox control as well. Thanks

    Read the article

  • Opening up process and grabbing window title. Where did I go wrong?

    - by user1632018
    In my application I allow for the users to add a program from a open file dialog, and it then adds the item to a listview and saves the items location into the tag. So what I am trying to do is when the program in the listview is selected and the button is pressed, it starts a timer and this timer checks to see if the process is running, and if it isn't launches the process, and once the process is launched it gets the window title of the process and sends it to a textbox on another form. EDIT: The question is if anyone can see why it is not working, by this I mean starting the process, then when it's started closing the form and adding the process window title to a textbox on another form. I have tried to get it working but I can't. I know that the process name it is getting is right I think my problem is to do with my for loop. Basically it isn't doing anything visible right now. I feel like I am very close with my code and im hoping it just needs a couple minor tweaks. Any help would be appreciated. Sorry if my coding practices aren't that great, im pretty new to this. EDIT:I thought I found a solution but it only works now if the process has been started already. It won't start it up. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Dim s As String = ListView1.SelectedItems(0).Tag Dim myFile As String = Path.GetFileName(s) Dim mu As String = myFile.Replace(".exe", "").Trim() Dim f As Process Dim p As Process() = Process.GetProcessesByName(mu) For Each f In p If p.Length > 0 Then For i As Integer = 0 To p.Length - 1 ProcessID = (p(i).Id) AutoMain.Name.Text = f.MainWindowTitle Timer1.Enabled = False Me.Close() Next Else ProcessID = 0 End If If ProcessID = 0 Then Process.Start(myFile) End If Next End Sub

    Read the article

  • Bind web user control property in markup

    - by Ian Levy
    I'm sure it's elementary but I can't figure it out. This does not work - the the binding expression is passed as string to the control: {<uc:usercontrol runtat="server" message='<%#Me.protectedVariable%>'/>} The code behind include a Page.Databind() call in page_load. But this does work: <uc:usercontrol runat="server" id="usercontrol1"/> And in code behind page_load: usercontrol1.message = Me.protectedVariable Do I have to bind from the code-behind? Is this a page life cycle issue?

    Read the article

  • how to find out which textbox is currenlty selected.

    - by abcdefghijklmnopqrstuvwxyz
    I have 3 text-boxes, how do I find out which text-box is currently selected (has focus). I am unable to come up with anything. Public Class Form1 Public activeTextBox As TextBox = CType(Me.ActiveControl, TextBox) Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click activeTextBox.Text = activeTextBox.Text & "This is text 1" End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click activeTextBox.Text = activeTextBox.Text & "This is the text 2" End Sub End Class

    Read the article

  • Variable Binding Class

    - by Davis
    Hi, I believe this is a tough one... I'm trying to create a collection of variable binding in a class. It is intended to look something like this: Dim x as integer, s as string Dim c as new VBindClass x = 1 s = "Hello" c.Add x, s Debug.Print c.value(x) '= 1 Debug.Print c.value(s) '= "Hello" Is there some function that allow us to retrieve a unique ID for a given variable and also get/set based on variable?

    Read the article

  • Strange DataTable behaviour

    - by DocSnuggles
    There´s a strange behaviour in my code which I can´t explain... I have worked arround it but I´d like to know the reason of this behaviour. My Code: If dataset.Tables.Count > 0 Then Dim rows() As DataRow = dataset.Tables(0).Select("FileID = " + fileid.ToString) For Each row As DataRow In rows... the one and only table in dataset is: 18 1 1 testpara42 19 1 2 Para2 23 2 1 Para1 24 2 2 Para42 Where the colums are: ParamID - FileID - ParaPos - Paravalue. I want do filter it so that the only rows I get are the ones with the correct fileid... the result when the selection string is "FileID = 1" is an array with 2 rows... everything is fine... but the filter string "FileID = 2" will return 0 Rows... A filter like "FileID < 1" returns 2 Rows correctly. I really cant´t explain this od behaviour, maybe one of the community does. The Table does have more entries but the Filter string just works with the "FileID = 1" selection. Excuse my bad english. Please explain my mistake to me.

    Read the article

  • EF - Entity Sql contains clausule with string

    - by zikrija
    Hi all, I have one question about EF. If I understand correctly EF does not support Contains. I try to achieve this: I have column(nvarchar) with this: for ex.row1. 1;3;4;5,row2. 3;4;6 row3. 7;8;16 etc. I have list(of string) with 1,6. My goal is to get row1 and row2 in result set. I try with linq to entity and with linq to sql but i can't get this right. I stuck with this and any help would be appreciated... Tnx

    Read the article

  • Using ExecuteQuery() with entity framework, entity class.

    - by sfreelander
    I am trying to jump from ASP Classic to asp.net. I have followed tutorials to get Entity Framework and LINQ to connect to my test database, but I am having difficulties figuring out ExecuteQuery(). I believe the problem is that I need an "entity class" for my database, but I can't figure out how to do it. Here is my simple code: Dim db as New TestModel.TestEntity Dim results AS IEnumerable(OF ???) = db.ExecuteQuery(Of ???)("Select * from Table1") From the microsoft example site, they use an entity class called Customers, but I don't understand what that means.

    Read the article

  • Stopping other subs from running while in a Sub

    - by Bigfatty
    Is there a way to stop other subs from running while in a separate sub. for instance say your in the sub CreateNumber() and the subs are setup like CreateNumber() AddNumber() DeleteNumber() Is there a way to be in CreateNumber() and call a function to stop AddNumber from running after creaetNumber() is finished? i just want my program to sit there to wait for an event to happen.

    Read the article

  • Class member variables, methods and their state

    - by codeMonkey
    How should class member variables be used in combination with class methods? Let's say I have a class 'C' with a member variable 'someData'. I call C.getData(), which does not return a value but instead puts data in C.someData. The class that instantiated 'C' first calls C.getData and then uses the data by accessing the member variable C.someData. I call C.getData() in the class that instantiated 'C' which is a function that returns data. I myself prefer the second way. But it also depends on the situation and it's a small difference. Is it 'bad' to have class methods that depend on the classes internal state? What are the best conventions?

    Read the article

  • Datagridview retains waitcursor when updated from thread

    - by Apeksha
    I have a DataGridView control in my Windows Forms Application. I am adding rows to the grid using a background thread. I change the form's cursor to Waitcursor when the process starts and back to Default when it ends. This works well for the form, but not for the grid. When the form's cursor is changed back to default, the grid's cursor does not change, although the cursor over the rest of the form does. Does this have anything to do with the fact that I am updating the grid from a background thread? (The cursor is being changed from the UI thread).

    Read the article

< Previous Page | 109 110 111 112 113 114 115 116 117 118 119 120  | Next Page >