|
Hello all,
How do I supplement the code below so that when a subitem is null from the database, the field in the listview is populated with a string; such as "n/a"?
There will be occasions when a field(s) corresponding to a subitem(s) might be null.
/////////////////////
Public Sub FillListView()
Dim fieldCtr As Short
Dim rdlv As SqlDataReader
rdlv = sqlCmd.ExecuteReader
Do While rdlv.Read
lvItems = New ListViewItem
lvItems.Text = Trim(rdlv(0))
For fieldCtr = 1 To rdlv.FieldCount() - 1
If rdlv.IsDBNull(fieldCtr) Then
lvitems.SubItems.Add("")
Else
lvitems.SubItems.Add(rdlv.GetString(1))
lvitems.SubItems.Add(rdlv.GetString(2))
lvitems.SubItems.Add(rdlv.GetString(3))
lvitems.SubItems.Add(rdlv.GetString(4))
lvitems.SubItems.Add(rdlv.GetString(5))
lvitems.SubItems.Add(rdlv.GetString(6))
lvitems.SubItems.Add(rdlv.GetDateTime(7))
'lvItems.SubItems.Add(rdlv.GetDateTime(8))
End If
Next fieldCtr
Me.lvSearchProperty.Items.Add(lvItems)
Loop
Me.btnSubmit.Enabled = False
End Sub
////////////////
Thanks a bunch,
Jaydeanster
Ben, is that you?
|
|
|
|
|
I have been trying to find a way to change the color of the actual tab control, not the individual pages. Does or has anyone found a way to accomplish this task? I have been trying to override the BackColor property but it doesn't seem to work.
Thanks!
|
|
|
|
|
The background color isn't supported by the TabControl. You can override the BackColor property all you want, it's not going to get drawn in that color unless you supply the drawing code to do it. Google for "ownerdraw tabcontrol" and you'll come up with all kinds of examples on how to do it.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hello all,
Two part question:
A. What am I doing wrong with the code below to generate the error on the Subject line above?
B. Is binding the best option (such as the one I have below) of displaying a specific record on a form?
//////////////////////
Private sqlConn As SqlConnection
Private SqlDataAdapter1 As SqlDataAdapter
Private sqlCmd As SqlCommand
Private DataSet11 As DataSet
Private Sub frmPropertyDetailTest_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim pintProperty As Short
Dim pbndtemp As Binding
sqlConn = New SqlConnection("Server=server;Database=db;User ID=us;Password=pw;Trusted_Connection=False")
sqlCmd = New SqlCommand
sqlCmd.Connection = sqlConn
sqlCmd.CommandType = CommandType.Text
sqlCmd.CommandText = "SELECT dbo.property.* FROM dbo.property"
sqlConn.Open()
SqlDataAdapter1 = New SqlDataAdapter
SqlDataAdapter1.SelectCommand = sqlCmd
DataSet11 = New DataSet
pintProperty = Me.SqlDataAdapter1.Fill(DataSet11)
pbndtemp = New Binding("Text", DataSet11, "property.PropertyID")
Me.txtPropertyID.DataBindings.Add(pbndtemp)
pbndtemp = New Binding("Text", DataSet11, "property.PropertyName")
Me.txtPropertyName.DataBindings.Add(pbndtemp)
pbndtemp = New Binding("Text", DataSet11, "property.Address1")
Me.txtAddress1.DataBindings.Add(pbndtemp)
pbndtemp = New Binding("Text", DataSet11, "property.Address2")
Me.txtAddress2.DataBindings.Add(pbndtemp)
pbndtemp = New Binding("Text", DataSet11, "property.City")
Me.txtCity.DataBindings.Add(pbndtemp)
pbndtemp = New Binding("Text", DataSet11, "property.State")
Me.txtState.DataBindings.Add(pbndtemp)
pbndtemp = New Binding("Text", DataSet11, "property.Postal")
Me.txtZip.DataBindings.Add(pbndtemp)
pbndtemp = New Binding("Text", DataSet11, "property.Country")
Me.txtCountry.DataBindings.Add(pbndtemp)
pbndtemp = New Binding("Text", DataSet11, "property.Business")
Me.txtBusinessNumber.DataBindings.Add(pbndtemp)
pbndtemp = New Binding("Text", DataSet11, "property.Fax")
Me.txtFaxNumber.DataBindings.Add(pbndtemp)
pbndtemp = New Binding("Text", DataSet11, "property.Support")
Me.txtSupportNumber.DataBindings.Add(pbndtemp)
pbndtemp = New Binding("Text", DataSet11, "property.Email")
Me.txtHotelEmail.DataBindings.Add(pbndtemp)
pbndtemp = New Binding("Text", DataSet11, "property.Url")
Me.txtWebsite.DataBindings.Add(pbndtemp)
pbndtemp = New Binding("Text", DataSet11, "property.Status")
Me.txtStatus.DataBindings.Add(pbndtemp)
pbndtemp = New Binding("Text", DataSet11, "property.Product1")
Me.txtProduct1.DataBindings.Add(pbndtemp)
pbndtemp = New Binding("Text", DataSet11, "property.Product2")
Me.txtProduct2.DataBindings.Add(pbndtemp)
pbndtemp = New Binding("Text", DataSet11, "property.Product3")
Me.txtProduct3.DataBindings.Add(pbndtemp)
pbndtemp = New Binding("Text", DataSet11, "property.Product4")
Me.txtProduct4.DataBindings.Add(pbndtemp)
pbndtemp = New Binding("Text", DataSet11, "property.Product5")
Me.txtProduct5.DataBindings.Add(pbndtemp)
pbndtemp = New Binding("Text", DataSet11, "property.Rooms")
Me.txtTotalRooms.DataBindings.Add(pbndtemp)
pbndtemp = New Binding("Text", DataSet11, "property.LiveDate")
Me.txtLiveDate.DataBindings.Add(pbndtemp)
pbndtemp = New Binding("Text", DataSet11, "property.HIBDate")
Me.txtHIBDate.DataBindings.Add(pbndtemp)
pbndtemp = New Binding("Text", DataSet11, "property.RevCategory")
Me.txtRevCat.DataBindings.Add(pbndtemp)
pbndtemp = New Binding("Text", DataSet11, "property.UtellSelection")
Me.txtUtellSelection.DataBindings.Add(pbndtemp)
pbndtemp = New Binding("Text", DataSet11, "property.Inventory")
Me.txtInventory.DataBindings.Add(pbndtemp)
pbndtemp = New Binding("Text", DataSet11, "property.JoinFee")
Me.txtJoinFee.DataBindings.Add(pbndtemp)
pbndtemp = New Binding("Text", DataSet11, "property.DevOwner")
Me.txtDevOwner.DataBindings.Add(pbndtemp)
pbndtemp = New Binding("Text", DataSet11, "property.SDMgr")
Me.txtSdMgr.DataBindings.Add(pbndtemp)
sqlConn.Close()
End Sub
///////////////////////
Thanks a bunch,
jaydeanster
I could have been a contender; I could have been somebody...
|
|
|
|
|
Hello
Try to use the property in DataMember Property Use with ur Database Name,(i.e) Dbo , In ur Fill statement the table name comes with DB name check the table mappings property
Ishak
|
|
|
|
|
It didn't work.
|
|
|
|
|
I am doing a Project in which I need to capture the snapshot of the desktop and send the captured image over the network to some other machine,
I have done the capturing part,I have no idea about how to transfer images over Network can u please help me!!!
|
|
|
|
|
Hello
Use the the Unifi.Utils DLL s that has contain many function for sending through network.then how u capture that Image and what function u use.
Ishak
|
|
|
|
|
sounds like something i could definetely use - where could i find it or information about it??
|
|
|
|
|
Hai
If u need contact me thro ugh mail rugfy@yahoo.com,I will send
Ishak
|
|
|
|
|
i m trying to make a vcd cutter like software in vb.net. i m using a binery reader to split the files.if i split the file from begnige it's playes fine but if i try to split it from sommeware middle the the clip is not working.can any one help me in this
|
|
|
|
|
Mike the Red already did. You've got alot of research to do in learning about the VCD format. I suggest Google or Yahoo to start.
We can answer questions about the VB/VB.NET language itself. What your asking has nothing to do with VB. We won't do your research for you because you wouldn't learn anything from us doing all the leg work.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
I do want to search paragraphs for strings.
I managed to do so, if the string is somewhere inbetween like the word "ten" in "I had ten cups of tea!".
But what I was not able to do is the following:
Searchstring is at the end of the sentence like "See you at ten." In there I did not mangage to erease the ".". Maybe the left function will work. But I have to take care not to eliminate too much, because I will have to keep 1.2 (meaning the dot inbetween) but I will have to remove it when it looks like "1.".
In general:
1.x (where x is any nonprintable character or nothing) should be 1
1.2.x (x like above) should be 1.2
but 1.2.3 should remain 1.2.3!
Any suggestions? I thought I could use the find operation which I got through recording a macro and using the find operation. But then I will get the 8 in 8.1 and 8.1.1 as well.
Well maybe I should really try to use the left and right function to eliminate the dots etc.
So any suggestion is very welcome!
Stephan.
|
|
|
|
|
Use the Instr() function. It is not affected by the character after the search pattern. For example, I tested Instr() on the folowing string:
"Ten people ordered ten cups of tea at ten."
and the function correctly returned the position of all three occurences of the substring "ten".
Robert
|
|
|
|
|
well yes I guess I will get every occuring of the string but I just tried and it didn't do it totally correct.
Example:
I do have the enumartion of the chapters.
Lets say they are 8, 8.1, 8.1.1, 8.2 and so on
If I do use instr() on them to search for "8" then it matches all of them! But I do not want 8.1, 8.1.1 and so on in this case.
What I want to do is a strict stringmatching. So like in your example if the last "ten" would look like "ten.twenty" then I would like to get the "ten" but ignore the ".twenty" afterwards.
So my search should parse through the paragraphs to find the string.
another example:
Let's say I do have these two paragraphs
If you want to know more about this product please have a look at clause 8.1.2.
To find the cheapest product in our shop please have a look at chapter 8.
So let's assume we do want to get the "8" but not the 8.1.2.
Instr() searches every occurence of "8" within a string. But in my example above there would be a hit in "8.1.2" aswell, which is not desired.
That's my problem. As you might have realized in the second paragraph, there is a dot and a linefead afterwards. So if I compared this string, after having split it in parts at the blanks, to "8" it would not match, because of the dot and linefead.
So what I am looking for is a solution to remove things like that, to get the hit, but not to influence the string matching in any other case, so e.g. if the "8" would have been somewere near the center of the paragraph, without anything behind.
Well, as I said in my last posting, I guess I will have to find a way using left() and right() to check what is behind the string, so to find out if it is 8.1.2 or 8. and linefeed.
But thanks anyway.
Stephan.
|
|
|
|
|
Hi,
In that case, use the String.ToCharArray to copy the text into a character array, then enumerate the characters looking for your target string. Then you can use the index to check the next <n> characters and determine whether you consider it a match or not.
It may take a little effort to get the loop logic correct, but so would using combinations of Left() and Right(). PLus I think it will run a lot faster than trying to do the same thing with left and right calls.
Good Luck,
Robert
|
|
|
|
|
Is this function available in VBA for Word? Because I can't find it there. And the editior just asks for the end of the command at the dot.
I guess this function is only available in .net but not in VBA.
Stephan.
|
|
|
|
|
I guess I could have done similar operations by using left() and right() parsing one character after the next one or copying it into an array, but well, I guess the result and the speed would be the same if not worse because of first copying it and afterwards parsing the array.
I did the following:
* I checked if the length of the searchstring is equal, then I found it
* I checked if the length of the searchstring is one smaller (or the string in the paragraph one bigger respectively). If so I take the last char (with right and length operations) and compare it to the non printable or to a dot (this will get the 8.1. or 8.1x where x is the linefeed or tab or ...)
* I checkd if the length of the searchstring is two smaller (or the string in the paragraph two bigger respectively). If so I once again take the last char to check, if it is a nonprintable. if it is, then I do have something like 8.1.x and not 8.1.2 e.g.
Except in the first case I do range.select the paragraph and have a look for this word, by using the comparestring. I just tried with a test document, and it worked with the testtext which is part of a bigger one. Well I know this might not be correct in every case but it matches most of these cases.
And besides I do parse every word in the paragraph, and if I find a possible match (using the InStr()) the operations above take place. To avoid parsing strings once again in the same paragraph, I marked those I already did the operations from above.
Well, I guess I will try the other solution (rebuild the tochararray operation and the comparing every char) as well to find out which of those has fewer errors or even none!
Thanks anyway!
Stephan.
|
|
|
|
|
I am trying to get label2 to divided evenly into label1. Numbers are being randomly placed into label1 and label2. I have written the following procedure but the numbers that are being placed in the label boxes are not dividing evenly. Below is my code. Any help is appreciated.
Sub fillnumdiv()
'Needed to make Do Until Loop work
lblNum1.Text = 3
lblNum2.Text = 2
Do
'Checks all of the conditions for the number to be placed in the label box for the first number.
Randomize()
lblNum1.Text = CInt(Int((145 * Rnd())))
Randomize()
lblNum2.Text = CInt(Int((145 * Rnd())))
Loop Until CDec(Int(lblNum1.Text) Mod Int(lblNum2.Text)) = 0 And
Int(lblNum2.Text) <> 0
End Sub
|
|
|
|
|
Why does this have the stench of homework around it?
Your constantly picking two random numbers and seeing if one divides evenly into the other. If it fails, you're picking two more, and so on, and so on... The chances of the RNG picking two number that divide evenly into each other are pretty low, so of course, it takes a long time to find two numbers that match your criteria.
I have no idea what your homework assignment is, but, how about picking a random number for one and then contantly trying random numbers to divide into it. In other words, pick a random number for label1, then in a do loop, keep picking random numbers until you find one that divides evenly into the first.
This will have the effect of trying to hit a stationary target, instead of a moving one.
There are other, much better ways of doing this, but, then again, it's your homework, isn't it?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
What you are saying makes more sense. Thanks. Really, it isn't a homework problem. I am doing a flashcard program for my daughter. She is learning how to add and subtract and I already have those done along with multiplication so I figured I would go ahead and put division in there. This is my first project. I am trying to teach myself how to use vb.net.
|
|
|
|
|
OK. If you want two numbers that are evenly divisible and do it quickly, generate two random numbers, put one of those numbers into one of the textbox's. Then, multiply the two numbers together and put the result in the other textbox. This will quickly give you two numbers that are evenly divisible.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
does anyone of you know how to get the length of a string array?
My code looks like this
<br />
mystring = ActiveDocument.Paragraphs(index)<br />
mydata = Split(mystring, " ")<br />
So in the beginning I do not know the size of the array. But I do need to know if the word I am searching for, is in this array. Therefor I have to parse the array to search it. But if I do not know the upper limit, this causes a "out of bounds" error. So I do need the upper limit to avoid the error to be thrown.
Could anyone please tell me how to get the length so I could do the following (in VBA!) ?
<br />
For i = 0 to upperlimit<br />
if mydata(i) = mysearchstring then<br />
do something<br />
end if<br />
Next
Thanks!
Stephan.
|
|
|
|
|
Try UBound(mydata,1)
An optimist's glass is half full.
A pesimist's glass is half empty.
An engineer goes and gets the right size glass.
|
|
|
|
|