Search Results

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

Page 103/179 | < Previous Page | 99 100 101 102 103 104 105 106 107 108 109 110  | Next Page >

  • How to write a contains statement to match a member of a class?

    - by afuzzyllama
    If I have the following structure: Public Class UserData Public ID As String Public Name As String End Class How can I select it in a conditional like this? Dim myUsers As New List(Of UserData) If myUsers.Contains(.ID = "1") = True Then ... I know that myUsers.Contains(.ID = "1") is totally wrong, but I am curious how to do something like that? Is it possible? Is this a job for LINQ?

    Read the article

  • Create a dynamic control and AddHandle WITH Values/Brackets

    - by Jacob Kofoed
    Hi, it seems that adding for example a button Dim myButton as New Button and then addHandler to mySub("lol", 255) is not possible. Where mySub is Shared Sub MySub(byRef myString as string, myInteger as Integer) So: addHandler myButton.click, addressOf mySub("lol", 255) - returns an error saying it does not work with parentheses or whatever. I somehow see why this might not be possible, so I'm looking for a work-around on this problem. Please help _jakeCake

    Read the article

  • Access varialbe from code behind via jQery

    - by Morron
    Hi, I have the following code that I want to return to a variable "t" in jQery: Code behind: Public Shared Function GetSomeText() As String Dim result = "This is from code behind" Return result End Function Caller variable in jQuery: //This is not working like that, I think var t = GetSomeText(); So, how can I make variable "t" get the "result" from Function GetSomeText from code-behind? Thank you.

    Read the article

  • tabcontainer button postback problem

    - by yousof
    I have a dropdownlist in my web page and two command buttons and a tabcontainer. The tabcontainer does not appear after the load of page according to my code. Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then TabContainer1.Visible = False If CtvAct.GetRecords("Fill_RequestTypeTb") = True Then ReqTypeCmbo.DataSource = CtvAct.MainDataset.Tables("tbOLRequestType").DefaultView ReqTypeCmbo.DataTextField = "RequestTypeName" ReqTypeCmbo.DataValueField = "RequestTypeId" ReqTypeCmbo.DataBind() Dim itm As New ListItem itm.Text = "-- ??? ??? ????? --" itm.Value = "-1" itm.Selected = True ReqTypeCmbo.Items.Insert(0, itm) ReqTypeCmbo.SelectedIndex = 0 End If End If End Sub Protected Sub PrntCmd_Click(ByVal sender As Object, ByVal e As EventArgs) Handles PrntCmd.Click TextBox6.Text = "gggg" End Sub If I press any button after page load the button work very selecting any item from dropdownlist make the tabcontainer appear but after the tabcontainer appear, the buttons does not work (postback) how can I solve these problems

    Read the article

  • What's wrong in this SELECT statement

    - by user522211
    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim SQLData As New System.Data.SqlClient.SqlConnection("Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Database.mdf;Integrated Security=True;User Instance=True") Dim cmdSelect As New System.Data.SqlClient.SqlCommand("SELECT * FROM Table1 WHERE Seats ='" & TextBox1.Text & "'", SQLData) SQLData.Open() Using adapter As New SqlDataAdapter(cmdSelect) Using table As New Data.DataTable() adapter.Fill(table) TextBox1.Text = [String].Join(", ", table.AsEnumerable().[Select](Function(r) r.Field(Of Integer)("seat_select"))) End Using End Using SQLData.Close() End Sub This line will be highlighted with blue line: TextBox1.Text = [String].Join(", ", table.AsEnumerable().[Select](Function(r) r.Field(Of Integer)("seat_select")))

    Read the article

  • How do I know if I'm iterating on the last item of the collection?

    - by Camilo Martin
    I want to do something different on the last KeyValuePair of the Dictionary I'm iterating on. For Each item In collection If ItsTheLastItem DoX() Else DoY() End If Next Is this possible? Edit: As Jon correctly remarks, Dictionaries are not the kind of thing that's sorted, so I should mention that I only want to do this when displaying results to the user, and it doesn't matter if later on the last item is different. In another note, I'll use my own answer but I'll accept the most upvoted one after I check back in some hours.

    Read the article

  • problem of setting cache as datatable and reading it

    - by MyHeadHurts
    and this is how i see if my cache is empty all my syntax errors are coming when i am trying to see if the cache is null and if it is to run the stored procedure If RadioButtonList1.SelectedIndex = 0 Then If Cache["netcache"] = null Then bcmd.CommandText = "yearlynetsales" Else btable = cache["netcache"] end if If RadioButtonList1.SelectedIndex = 1 Then If Cache["salescache"] = null Then bcmd.CommandText = "yearlysales" Else btable = cache["salescache"] end if end if this is how i set my cache If RadioButtonList1.SelectedIndex = 0 Then Cache.Insert("netcache", bTable) ElseIf RadioButtonList1.SelectedIndex = 1 Then Cache.Insert("salescache", bTable) ElseIf RadioButtonList1.SelectedIndex = 2 Then Cache.Insert("cxsalescache", bTable) ElseIf RadioButtonList1.SelectedIndex = 3 Then Cache.Insert("cxvaluecache", bTable) ElseIf RadioButtonList1.SelectedIndex = 4 Then Cache.Insert("othersalescache", bTable) ElseIf RadioButtonList1.SelectedIndex = 5 Then Cache.Insert("inssalescache", bTable) End If

    Read the article

  • Where to find a unique session ID at design time in .Net WinForms.

    - by Jules
    I've created a custom clipboard because it's not possible to make my whole class map serializable - which is a requirement for the windows clipboard. However, I need to distinguish between users who are using my clipboard through a unique id. Basically, I want to be able identify a person who is sat at one PC with one or more copies of visual studio (or similar) open. How do I do that? ps: This is at design-time. pps: It's not critical that it should work between copies of visual studio. One copy would be fine, or even one design surface.

    Read the article

  • How do I convert from a possibly Windows 1252 'ANSI' encoded uploaded file to UTF8 in .NET?

    - by qqq123
    I've got a FileUpload control in an ASP.NET web page which is used to upload a file, the contents of which (in a stream) are processed in the C# code behind and output on the page later, using HtmlEncode. But, some of this output is becoming mangled, specifically the symbol '£' is output as the Unicode FFFD REPLACEMENT CHARACTER. I've tracked this down to the input file, which is Windows 1252 ('ANSI') encoded. The question is, How do I determine whether the file is encoded as 1252 or UTF8? It could be either, and How do I convert it to UTF8 if it is in Windows 1252, preserving the symbol £ etc? I've looked online but cannot find a satisfactory answer.

    Read the article

  • Cannot add an entity that already exists. (LINQ to SQL)

    - by Vicheanak
    Hello guys, in my database there are 3 tables CustomerType CusID EventType EventTypeID CustomerEventType CusID EventTypeID Dim db = new CustomerEventDataContext Dim newEvent = new EventType newEvent.EventTypeID = txtEventID.text db.EventType.InsertOnSubmit(newEvent) db.SubmitChanges() 'To select the last ID of event' Dim lastEventID = (from e in db.EventType Select e.EventTypeID Order By EventTypeID Descending).first() Dim chkbx As CheckBoxList = CType(form1.FindControl("CheckBoxList1"), CheckBoxList) Dim newCustomerEventType = New CustomerEventType Dim i As Integer For i = 0 To chkbx.Items.Count - 1 Step i + 1 If (chkbx.Items(i).Selected) Then newCustomerEventType.INTEVENTTYPEID = lastEventID newCustomerEventType.INTSTUDENTTYPEID = chkbxStudentType.Items(i).Value db.CustomerEventType.InsertOnSubmit(newCustomerEventType) db.SubmitChanges() End If Next It works fine when I checked only 1 Single ID of CustomerEventType from CheckBoxList1. It inserts data into EventType with ID 1 and CustomerEventType ID 1. However, when I checked both of them, the error message said Cannot add an entity that already exists. Any suggestions please? Thx in advance.

    Read the article

  • A good UI design for rating in .Net

    - by Ben
    Hi, im trying to add a "rating" system to an existing form (i.e 1 star, 2 Star or poor, average,good,excellent etc). Does anyone know of a way to achieve this that is aesthetically pleasing with good UX either in .Net or a free 3rd party control? Thanks

    Read the article

  • The cost of finalize in .Net

    - by Jules
    (1) I've read a lot of questions about IDisposable where the answers recommend not using Finalize unless you really need to because of the process time involved. What I haven't seen is how much this cost is and how often it's paid. Every millisecond? second? hour, day etc. (2) Also, it seems to me that Finalize is handy when its not always known if an object can be disposed. For instance, the framework font class. A control can't dispose of it because it doesn't know if the font is shared. The font is usually created at design time so the user won't know to dispose it, therefore finalize kicks in to finally get rid of it when there are no references left. Is that a correct impression?

    Read the article

  • Combining two .png images into one image using .NET

    - by Omega
    I have two (actually many) .png images in my application. Both have transparent areas here and there. I want, in my application, to take both images, combine them, and display the result in a picture box. Later I want to save the result through a button. So far I managed to find the two images and combine them, but it seems the transparency thing won't work. I mean, if you put one image over another, only the top image is visible as the result because, apparently, the image's background is a plain white box. Which is not. Here is a bit of my code: Dim Result As New Bitmap(96, 128) Dim g As Graphics = Graphics.FromImage(Result) Dim Name As String For Each Name In BasesCheckList.CheckedItems Dim Layer As New Bitmap(resourcesPath & "Bases\" & Name) For x = 0 To Layer.Width - 1 For y = 0 To Layer.Height - 1 Result.SetPixel(x, y, Layer.GetPixel(x, y)) Next Next Layer = Nothing Next resourcesPath is the path to my resources folder. Bases is a folder in it. And Name is the image's name. Thank you.

    Read the article

  • Error debugging - Conversion from String to Double

    - by Jamie Taylor
    I'm doing some error debugging trying to get the errors on our website down to a minimum and there seems to be an error that is popping up quite a lot Conversion from string "" to type 'Double' is not valid. I'm unable to replicate this problem but I can see that it is happening. I've been looking through the code in one of the pages and strolled across this Dim varWeek As String If varWeek < 10 Then 'Do something' End If Could this be causing the problem as it is trying to see if a String is less than 10 which is an Integer? As I said before as I am unable to see this error in the first place so changing this to an Integer doesn't change anything on my system. Thanks.

    Read the article

  • Array index is not accessable because it is Friend

    - by user3738194
    I am getting and error when I bring my code into another project. In a blank project it works fine, I really have no idea how to get around it, here is the error Error 1 'System.Data.Index' is not accessible in this context because it is 'Friend'. Dim DataString As String = txtAdvancedCommand.Text ' Create an array containing from each letter in Textbox Dim charArray() As Char = DataString.ToCharArray For index = 0 To charArray.GetUpperBound(0) <-----ERROR on word index Try 'Now lets send the data If SerialPort.IsOpen Then SerialPort.Write(charArray(index) & vbCrLf) <-----ERROR on word index Else ConnectSerial() SerialPort.Write(charArray(index) & vbCrLf) <-----ERROR on word index End If Catch e As Exception txtLog.AppendText(e.Message & vbCrLf) End Try Next now the project I am bringing into has a DLL and I suspect it has something to do with it, I cannot get the source code to the DLL so is there another way around this?

    Read the article

  • Strange Effect with Overridden Properties and Reflection

    - by naacal
    I've come across a strange behaviour in .NET/Reflection and cannot find any solution/explanation for this: Class A { public string TestString { get; set; } } Class B : A { public override string TestString { get { return "x"; } } } Since properties are just pairs of functions (get_PropName(), set_PropName()) overriding only the "get" part should leave the "set" part as it is in the base class. And this is just what happens if you try to instanciate class B and assign a value to TestString, it uses the implementation of class A. But what happens if I look at the instantiated object of class B in reflection is this: PropertyInfo propInfo = b.GetType().GetProperty("TestString"); propInfo.CanRead ---> true propInfo.CanWrite ---> false(!) And if I try to invoke the setter from reflection with: propInfo.SetValue("test", b, null); I'll even get an ArgumentException with the following message: Property set method not found. Is this as expected? Because I don't seem to find a combination of BindingFlags for the GetProperty() method that returns me the property with a working get/set pair from reflection.

    Read the article

  • Linq Query ignore empty parameters

    - by Cj Anderson
    How do I get Linq to ignore any parameters that are empty? So Lastname, Firstname, etc? If I have data in all parameters it works fine. refinedresult = From x In theresult _ Where x.<thelastname>.Value.TestPhoneElement(LastName) Or _ x.<thefirstname>.Value.TestPhoneElement(FirstName) Or _ x.<id>.Value.TestPhoneElement(Id) Or _ x.<number>.Value.TestPhoneElement(Telephone) Or _ x.<location>.Value.TestPhoneElement(Location) Or _ x.<building>.Value.TestPhoneElement(building) Or _ x.<department>.Value.TestPhoneElement(Department) _ Select x Public Function TestPhoneElement(ByVal parent As String, ByVal value2compare As String) As Boolean 'find out if a value is null, if not then compare the passed value to see if it starts with Dim ret As Boolean = False If String.IsNullOrEmpty(parent) Then Return False End If If String.IsNullOrEmpty(value2compare) Then Return ret Else ret = parent.ToLower.StartsWith(value2compare.ToLower.Trim) End If Return ret End Function

    Read the article

  • Directory.GetFiles returning entire path, I only want the filename?

    - by blerh
    This is the code I have set up to scan a directory of files: Dim fileArray() As String fileArray = Directory.GetFiles(System.AppDomain.CurrentDomain.BaseDirectory & "help\") And it successfully gets all files in the directory, but it gets their absolute paths aswell. For example, one of the entries in fileArray() is: F:\Project\Project\bin\x86\Debug\help\book_troubleshoot.html And I want it to just be: book_troubleshoot.html Is there a way to do this without parsing through all the array entries to trim off the path? Thanks.

    Read the article

  • Getting Stored Procedure Information from .Net

    - by Ben
    Hi, I am trying to get some data relevant to a stored procedure (or funtion) back from a database using .Net. The first thing I need to be able to do, is get the stored proc from the database and turn it into string format. The information I need is: The return set of columns, tables used within the SP, Stored Procedures called from the SP. The only way of doing this at the moment that i can think of, is though parsing the text and looking for keyword matches. Is there a better way of doing this? Any ideas? Thanks.

    Read the article

  • Mono - Could not find a 'Sub Main' in ''

    - by lampej
    I started a new solution (with multiple projects) and am trying to get it to build. Initially I was getting an internal compiler error and thought maybe it had to do with MySql, so I removed all references to MySql. Now I am getting the error "Could not find a 'Sub Main' in ''". I have made sure that all of my projects have a Main subroutine like this: Public Shared Sub Main() End Sub 2 out of the 7 projects will compile. I don't know what makes these projects different from the others, and the error message isn't very helpful. Any experience with this one?

    Read the article

  • Setting Nullable Integer to String Containing Nothing yields 0

    - by Brian MacKay
    I've been pulling my hair out over some unexpected behavior from nullable integers. If I set an Integer to Nothing, it becomes Nothing as expected. If I set an Integer? to a String that is Nothing, it becomes 0! Of course I get this whether I explicitly cast the String to Integer? or not. I realize I could work around this pretty easily but I want to know what I'm missing. Dim NullString As String = Nothing Dim NullableInt As Integer? = CType(NullString, Integer?) 'Expected NullableInt to be Nothing, but it's 0! NullableInt = Nothing 'This works -- NullableInt now contains Nothing. How is this EDIT: Previously I had my code up here so without the explicit conversion to 'Integer?' and everyone seemed to be fixated on that. I want to be clear that this is not an issue that would have been caught by Option Strict On -- check out the accepted answer. This is a quirk of the string-to-integer conversion rules which predate nullable types, but still impact them.

    Read the article

  • Different approaches for finding users within Active Directory

    - by EvilDr
    I'm a newbie to AD programming, but after a couple of weeks of research have found the following three ways to search for users in Active Directory using the account name as the search parameter: Option 1 - FindByIdentity Dim ctx As New PrincipalContext(ContextType.Domain, Environment.MachineName) Dim u As UserPrincipal = UserPrincipal.FindByIdentity(ctx, IdentityType.SamAccountName, "MYDOMAIN\Administrator") If u Is Nothing Then Trace.Warn("No user found.") Else Trace.Warn("Name=" & u.Name) Trace.Warn("DisplayName=" & u.DisplayName) Trace.Warn("DistinguishedName=" & u.DistinguishedName) Trace.Warn("EmployeeId=" & u.EmployeeId) Trace.Warn("EmailAddress=" & u.EmailAddress) End If Option 2 - DirectorySearcher Dim connPath As String = "LDAP://" & Environment.MachineName Dim de As New DirectoryEntry(connPath) Dim ds As New DirectorySearcher(de) ds.Filter = String.Format("(&(objectClass=user)(anr={0}))", Split(User.Identity.Name, "\")(1)) ds.PropertiesToLoad.Add("name") ds.PropertiesToLoad.Add("displayName") ds.PropertiesToLoad.Add("distinguishedName") ds.PropertiesToLoad.Add("employeeId") ds.PropertiesToLoad.Add("mail") Dim src As SearchResult = ds.FindOne() If src Is Nothing Then Trace.Warn("No user found.") Else For Each propertyKey As String In src.Properties.PropertyNames Dim valueCollection As ResultPropertyValueCollection = src.Properties(propertyKey) For Each propertyValue As Object In valueCollection Trace.Warn(propertyKey & "=" & propertyValue.ToString) Next Next End If Option 3 - PrincipalSearcher Dim ctx2 As New PrincipalContext(ContextType.Domain, Environment.MachineName) Dim sp As New UserPrincipal(ctx2) sp.SamAccountName = "MYDOMAIN\Administrator" Dim s As New PrincipalSearcher s.QueryFilter = sp Dim p2 As UserPrincipal = s.FindOne() If p2 Is Nothing Then Trace.Warn("No user found.") Else Trace.Warn(p2.Name) Trace.Warn(p2.DisplayName) Trace.Warn(p2.DistinguishedName) Trace.Warn(p2.EmployeeId) Trace.Warn(p2.EmailAddress) End If All three of these methods return the same results, but I was wondering if any particular method is better or worse than the others? Option 1 or 3 seem to be the best as they provide strongly-typed property names, but I might be wrong? My overall objective is to find a single user within AD based on the user principal value passed via the web browser when using Windows Authentication on a site (e.g. "MYDOMAIN\MyUserAccountName")

    Read the article

  • How to make Event visible?

    - by eflles
    Inside a Silverlight library project I have a public event, which is not visible for other classes. How can I make the event visible? When I try the following code, I can not locate the event in the "ReceivingClass". .dll - file: Public Class MyClass Public Event MyEvent(ByVal sender As Object, ByVal e As EventArgs) Public Sub OnStart() RaiseEvent MyEvent(Me, new EventArgs) End Sub End Class Silverlight app: Imports MyClass Public Class ReceivingClass Public Sub New() Dim myClass As new MyClass AddHandler myClass.MyEvent, AddressOf Me.EventHandler End Sub Private Sub EventHandler(ByVal sender As Object, ByVal e As EventArgs) 'Handle Event End Sub End Class

    Read the article

< Previous Page | 99 100 101 102 103 104 105 106 107 108 109 110  | Next Page >