is the task shown? [closed] - vba

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 3 months ago.
Improve this question
I want to find out is the task actual shown or not. (Possible it's not shown by filter, or the outline structure is collapsed)
I want to handle it in VBA.

To determine if a task is visible, all that is really needed is to use the Find method of the Application object which returns True if visible. However, the Find method moves the active cell to that task if found and selects the entire row. This is often undesirable for the end-user.
This function returns True/False depending on if the task is visible, and resets the active cell.
Function TaskIsVisible(uid As Long) As Boolean
Dim curTaskUID As Long
curTaskUID = ActiveCell.Task.UniqueID
Dim curField As String
curField = ActiveCell.FieldName
TaskIsVisible = Application.Find("Unique ID", "equals", uid)
Application.Find "Unique ID", "equals", curTaskUID
Application.SelectCellLeft
Do While ActiveCell.FieldName <> curField
SelectCellRight
Loop
End Function
Note: Any task field can be used with the Find method and the field does not have to be in the current view. Unique ID is best in this case since it's guaranteed to not match any other task.

Related

Visual Basic - How to save an image that is in the first column of a listview control? [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
Have a listview object with some columns and some rows. The first one has an image for each line (different images). I want to save each image from each row. The filename doesn't matter (could be imgyyyyMMddHHmmss.jpg, for example). struggling to get the image. The following code does not work (the listview item cannot be converted to string).
Any clues?
Thanks
Dim tmpIndex1 As Integer
Dim tmpImage As Image
For tmpIndex = 0 To listView1.Items.Count
tmpImage = lsvAddOrderItems.Items(tmpIndex1)
tmpImage.Save()
Next
A ListView control cannot contain an Image object within one of its Items.
If you want to add images to a ListView you must associate an ImageList to the ListView control.
Then to your ImageListControl load the images with its Key
Once you have all your images inside your ImageListControl, you will fill your items with your ListViewControl with the imageKey of your ImageListControl.
Then you must change your code to:
For tmpIndex = 0 To listView1.Items.Count
tmpImage = ImageListControl.Images(lsvAddOrderItems.Items(tmpIndex1).ImageKey)
tmpImage.Save()
Next
This way the conversion will not fail.

Make form back color = textbox input [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I have a textbox, i want the user to be able to type like a color code or something in the textbox and the form back color to change to the specific color the user typed.
Help?
If you mean that the user will be typing in something like black or blue then you need the .GetColorFromName function. The code below takes the text from TextBox1 and checks to make sure that the color is recognized. If so, the Form.BackColor is set to that colour. This way if the user mis-types a color, you wont get an error. Also, it doesn't seem to matter if you type black or Black
Dim c As Color = System.Drawing.Color.FromName(TextBox1.Text)
If c.IsKnownColor Then
Me.BackColor = c
End If
If you want to add a keyword "color" to the begining of the textbox, try this instead ..
Dim commandString As String = TextBox1.Text
If commandString.ToLower.StartsWith("color") Then
'remove the 5 letters making "color" and a space
commandString = commandString.Remove(0, 6)
Dim c As Color = System.Drawing.Color.FromName(commandString)
If c.IsKnownColor Then
Me.BackColor = c
End If
End If

Comparing a Location [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
How do I check if a Location is, for example, x = 100, y = 100?
' Compile error
If Button1.Location = 0, 0 Then
Button1.Visible = False
End If
The Location property is of type Point so you have to compare it to a Point value.
If you want a Point value with coordinates (0,0) then you can use the Shared field Point.Empty.
If you want other coordinates then you'll have to create a Point value yourself.
If Button1.Location = New Point(100, 100) Then
Button1.Enabled = False
End If
Alternatively, you could compare the Top and Left properties, each of which are type Integer, separately.
It appears that what you actually want to know is not what I read and what I provided an answer for previously. I'm not sure whether that's your fault, someone else's fault roa combination of the two. Either way, I will now answer the question of how to centre a form if it is located in the top-left of its containing window.
Firstly, while creating a new Point from (0,0) is not exactly wrong, it's more correct to use Point.Empty.
As for the actual issue, it's useless to set the StartPosition after you've called Show because StartPosition represents the position in which the form starts. If it's already been shown then it's already started so any change to StartPosition will have no effect.
You need to position the form manually by setting its Location explicitly, based on the relation between its size and that of the window you're positioning it relative too. The fact that you're using CenterParent suggests that that's not the screen, so you'll need to qualify that if you want a specific example. You shouldn't need a specific example though, because it's simple arithmetic of the sort taught in primary school.
If Button1.Location.X = 0 And Button1.Location.Y = 0 Then
Button1.Visible = False
End If

How do I hide multiple pictureboxes at once? [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
My code:
Case 1 To 9
txtPlanet.Text = "Mercury"
pl1.Show()
pl2.Hide()
pl3.Hide()
pl4.Hide()
pl5.Hide()
pl6.Hide()
pl7.Hide()
pl8.Hide()
pl9.Hide()
How do I make it so it does it like this: pl1.Show, pl2-9.Hide.
If that isn't possible, what's the best solution to neaten the code?
Thanks in advance.
This is what I'd do. It assumes you're using VB.NET in Visual Studio 2010.
Dim pictureBoxes = {pl1, pl2, pl3, ....}
Dim shownPicture = Nothing
Select Case planetToShow
Case "Mercury"
shownPicture = pl1
Case "Venus"
shownPicture = pl2
....
End Select
For Each pic in pictureBoxes.Except({shownPicture})
pic.Hide()
Next
shownPicture.Show()
a select case is not well written, becuase you only wrote the case, there has to be a if function statement.
Select case textPlanet.Text
case "Mercury"
pl1.Show()
pl2.Hide()
pl3.Hide()
pl4.Hide()
pl5.Hide()
pl6.Hide()
pl7.Hide()
pl8.Hide()
pl9.Hide()
case "Venus"
// Repeat above statements with pl2.Show() & pl1.Hide
//Repeat each case for each planet
end case
i am not sure strings work correctly with cases, if not try with integer
Try searching for Controls with .Controls.Find()
This returs an Array of the found Controls.
Then go through the Controls with for each...
You have to search for controls from the parent control. I.E. Form, Groupbox ...

VB.NET Grab URL From Webbrowser1 [closed]

Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
How can i grab this url and paste it in a textbox?
Logout (Kassy Daniels) ยท Help
from this in webbrowser1
i want it to grab the /logout.php? url cause each user is different
and just paste it in a textbox1 when you hit a button
Assuming your webbrowser is WebBrowser1,
Using WebBrowser1.Document.Links will get you a HTMLElementCollection of all of the links on the page.
You can iterate through those, and check the OuterHtml element of each of those links (which will give you a string that contains the raw link, the IDs, etc.) for the text your are looking for (in this case logout?).
Using the substring command, extract that URL, and eliminate the surrounding text, and you can plug that right into the textbox.
Update: Using Firebug or your favorite DOM tool, you can find that the logout link is in the root div of the document
Dim rootDiv As HtmlElement = WebBrowser1.Document.GetElementById("root")
Dim links As HtmlElementCollection = rootDiv.GetElementsByTagName("a")
Dim index As Integer
For i As Integer = 0 To links.Count - 1
If links(i).InnerHtml.Contains("Logout") Then
index = i
Exit For
End If
Next i
Dim stringofLink As String = links(index).OuterHtml
If the page changes in structure, this should be somewhat resilient to it, but you may need to generalize it further. Process stringofLink however you want to break it up (find the ampersand that you need and then copy from the question mark to that point).