Visual Basic Components - vba

My visual Basic will not allow me to access the components this was not a problem till recently
lblCharactorName.txt = "Karle"
will appear with Red Error squiggles under the lblCharactorName
please help
the (name) property is labeled right, it just won't let me access my labels and Textboxes

In VBA Label controls don't have .txt or .text, you should use instead .Caption = "my text"

Related

ListView Not Displaying Added Text

Background:
Hello everyone, I'm not new to visual basic or programming. I just find it the fastest to make a GUI in visual basic for various programs; however, I'm having a recent issue.
I have a form with a ListView control that I populate using a textbox and a button.
the code I use for the button is:
Code:
listview1.items.add(textbox2.text)
Pretty simple code that has always worked. I changed a few properties on my ListView as well, and I will list them. I just don't know what is going on.Here's a list of the properties changed (everything else is default):
Properties:
BackColor = DarkGray
BorderStyle = FixedSingle
HeaderStyle = None
MultiSelect = False
View = Details
All properties were changed via the properties tab and not through code. I want to be able to add text to the control. I'm not adding any subitems either. I'm just confused because this code has always worked, and I've never had this issue. I'm also using Visual Basic 2010 Express Edition if that helps.
If the added item in ListView is not displaying then check the ListView.View property. if this property has set to Detail view then Columns must be added in that listView control otherwise added item will not display.
Make sure item is added correctly.
Dim item As ListViewItem = listView1.Items.Add("Item Text") ' This text will be displayed in first column. The column index will be 0
' Further values will be added in SubItem
item.SubItems.Add("Sub Item1")
item.SubItems.Add("Sub Item2")
item.SubItems.Add("Sub Item3")

How to scroll vertically & programmatically a textbox on a form with Visual Studio 2010 express with Vbasic

I am using Visual Studio Express 2010 with visual basic. I am trying to both learn and test the product enough in 30 days to see if the regular Visual Studio 2010 (Vbasic in particular) will meet my needs. Here's the problem/question. I have an output kind of textbox on a form, textbox1, which is written to programmatically. I have set it to be multiline, enabled, read only, and scrollbar: vertical. I need to fix it so that the scroll thumb moves to the bottom automatically each time the text is overwritten or appended to. (I am overwriting, but actually adding to the textbox (TextBox1.Text & Chr(13) & Chr(10) & newtextdata). The values properties of TextBox1 includes a minimum which is zero and a maximum which is 100. Changing those doesn't seem to help. There is no autoscroll property on a textbox. I even tried setting the textbox to scrollbars: none and then adding from the toolbar a VScrollBar, but I couldn't get it to hook up to TextBox1 and I don't know how to make that one scroll programmatically to the bottom either. Would you please give me the necessary code? Also, if there needs to be a system import, would you please mention that too? This is a make or break feature for me. If this product and vbasic won't do this, then I have to look at something else. I have searched already through three books plus online here and can't figure it out. Thanks so much!
Thanks to the suggestion here (from David), I came up with something that works, and because it wasn’t exactly the same as David’s suggestion, I wanted to share the specifics with you…
First, I added a public sub…
PublicClassForm1
PublicSub ScrollToCaret()
EndSub
Then in an Accept button routine for the user‘s input, I did the following….
OutputTextBox.ScrollToCaret()
OutputTextBox.SelectedText = strTextBeingAdded + _
Microsoft.VisualBasic.vbCrLf
I had a problem, though with the OutputTextBox.Text set on the Design page and had to erase it and put it into the Form load event so that it would scroll to caret there too...
PrivateSub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) HandlesMyBase.Load
OutputTextBox.ScrollToCaret()
OutputTextBox.SelectedText = "Initial Description” & strWrap + _
Microsoft.VisualBasic.vbCrLf
Thanks for the comment that led me to this!
Use the SelectionStart property:
TextBox.SelectionStart = Len(TextBox.Text)

Visual Basic: How to replace selected NumericUpDowns with ComboBoxes

Is it possible to replace the selected NumericUpDown controls with ComboBoxes?
I understand that not all properties can be conserved but the only properties I need are the location and the size.
The workflow I have in mind is as follows:
Select certain NumericUpDowns
Click replace with... and then select ComboBoxes (or any other approach)
Where the NumericUpDowns were, there are now ComboBoxes of the same size
The reason I want to do this is that I have to put together a GUI with multiple tabs. Each tab page has a list of Labels with either NumericUpDowns or ControlBoxes next to it. The order of the controls changes per tab. I just want to copy the items on the first tab and paste them on the other tabs. Then per tab I only have to change certain NumericUpDowns into ComboBoxes.
I started with VB yesterday so I might be overlooking something.
The quickest is doing it manually, we cant change your GUI remotely - since you are at an entry level with a language you do not know well, RAD is the best recommendation - this way you can study what it does - just like learning HTML with DreamWeaver's RAD tools.
Since your interested, (I know your new to VB so I'dd make it heaps clear) you do these steps:
a) Open Winforms VS 2008 solution
b) Click the File > Create New Project > WinForms
c) Double click the form and it will show you the forms code
d) Then in the constructor method you will see the line InitializeComponent
e) Right Click on this method call and chose Goto Definition
f) This will show you the code that populates the form with controls
g) Then for each form I'm suggestion you replace all the NumericUpDown's with ComboBoxes in the xyz.Designer.vb file
However I'd really recommend doing it with Visual Studio IDE. Don't be frightened.
Private sub Replace_By_ComboBox(ByVal nud As NumericUpDowns)
'Create new combo box
Dim cbx As New ComboBox
cbx.Left = nud.Left
cbx.To = nud.Top
cbx.Width = nud.Width
cbx.Height = nud.Height
cbx.Visible = True
cbx.Enabled = True
'Add the combo box
nud.Parent.Controls.Add(cbx)
'Remove the NumericUpDowns
nud.Parent.Controls.Remove(nud)
End Sub

Microsoft office Macro - Why is the document jumping around?

This if the first time I write a Microsoft Office Macro.
Basically, we have a few check boxes on page 1 and when one of them is checked, I need to auto-fill a text box on page 10 depending on which check box was checked. So each checkbox "on Entry" runs a macro.
Say the options are "Outstanding", "Exceeded" and "Unsatisfactory". When "Outstanding" is checked, that text box will be filled with "O", when "Exceeded" is checked, the text box will be filled with "E"
So the issue right now is, whenever I check the check box on page 1, suddenly, the document will jump to Page 10.
All I did was doing something like
oFFld("Text23").Result = "O"
I need it to stay on the same page! If I got rid of the above code, setting a value to the textbox, then nothing happens and I will stay on page 1.
What's going on? Any advice is greatly appreciated it.
ps:
it's word 2007
Never mind.
I was using an evaluation expression as in
If OFFld("Text23").Result = "blah" Then
whenever I do that, it'll jump to the page 10. Took care of it in another way. solved.
See answer in Suppress unwanted jumping/scrolling on Word 2013 VBA Script for details, but essentially you want to use the Bookmark object rather than the FormField object to access the result property.

Text input issues with Visual Basic

Ok, I'm writing a program in vb. It's simply a text editor. However i've run into a little snag. My program has options to click a button and text is inserted into the text box. I am using this line:
textbox.AppendText (sometext)
Now this code works great if i want the text to be added at the bottom of the page. So here's my question, is there any way to modify or maybe replace this code so that the text is inserted were the cursor is?
Try setting .SelectedText property or using .Paste(String).
Not through the textbox control itself, as far as I know. You will need to use the SelectionStart property to manually insert the text.
textBox1.Text = textBox1.Text.Substring(0, textBox1.SelectionStart) & "INSERTEDTEXT" & textBox1.Text.Substring(textBox1.SelectionStart)
This is assuming you want to insert the text and not just replace it.