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 5 years ago.
Improve this question
I try to make a program to calculate integrals. I want to read the equation from a textbox and i don't know how to store it. For example i write in the textbox : 3x^2+2x+1. How can i make some arrays to store every member of that equation and to solve it ?
You really should include code if you want people to help you. I have a suggestion but it really all depends. Are you only wanting to put the numbers in an array or all characters and symbols? Or are you wanting to put the entire equation as one entry in the array? I am not sure an array would be the best route to go for this sort of thing. But whatever.
Public Class Form1
Dim EqArray() As string
Public Sub Array_Entry()
Dim NewEntry as string = textbox1.text
EqArray.items.add(NewEntry)
msgbox(NewEntry & " has been added.")
End Sub
End Class
Related
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 2 years ago.
Improve this question
I'm looking to somewhat generate a "table of contents" of sorts with BeautifulSoup. I've tried extracting the h1, h2, and h3 tags and building a string accordingly, but I'm struggling because I retain the tag content. I'm also struggling in general to get the format correct. Here's what I want.
Let's say I have a file, test.html
<h1>First Part<h1>
<h2>First sub Part<h2>
<h3>First sub sub part<h3>
<h1>Second Part<h1>
<h2>Second sub Part<h2>
<h3>Second sub sub part<h3>
Then, I want to end up generating the HTML that would give me this:
First part
First sub part
First sub sub part
The bullet's dont look great because of Stack's formatting (there may be functionality for this, but I'm not aware of how to use it), but you get the gist. Any ideas?
Thanks!
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 2 years ago.
Improve this question
I am completing an NEA for my GCSE assessment, and need help with a certain piece of code.
The task requires me to create a music quiz in which the Artist of the song and the first letter of each word of the song title is displayed. I don't know how I would even start to do this. Currently I have the songs in an array from an external file and can output a random one based of a random number generator but need help manipulating the string.
Any help would be much appreciated,
Thanks.
You can read each character individually in VB.NET by accessing it as if it were an array. So if you have for example:
Dim s As String = "abcdef"
Then if you use brackets like it is an array you can return a single character.
So to get the first element would be:
Dim first_letter As String = s(0) ' This would return just "a" as it is the first item and arrays are 0 indexed
And to find each element you can do s(1), s(2) etc or whatever your string is called as a string is an array of characters so they can be accessed and manipulated like one.
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 am new to VBA,I have a string I_HEAD_FOR
I wanted to extract the substring which is started and ended by special character '_'(Underscore) in VBA.
I need code snippet which can do above task,Could you please help me with it
Here in this case The code should extract substring HEAD
This the idea is from:
I_HEAD_FOR
to get as a result: HEAD
How about:
Public Function UnderScore(s As String) As String
UnderScore = Split(s, "_")(1)
End Function
If you want to use Excel, without VBA, this is the way you should think to make the formula:
On which position is the first _ sign?
Knowing the first position of the first sign, can I find the second _ sign?
Now, knowing the first and the second position, is there a way to extract only the string, which is between the two positions?
How can I unite the whole party into one formula, without getting crazy?
The Formulas SEARCH and MID together are pretty powerful. The SEARCH formula has optional value, saying where should you start search (see the second formula). Thus, we add +1 to the first found value. In the second formula, the -1 is added, because we do not want the position of the _, but the position before.
The formulas in text:
=SEARCH("_",A1,1)
=SEARCH("_",A1,SEARCH("_",A1,1)+1)-1
=MID(A1,B1+1,B2-B1)
=MID(A1,SEARCH("_",A1,1)+1,SEARCH("_",A1,SEARCH("_",A1,1)+1)-1-SEARCH("_",A1,1))
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 8 years ago.
Improve this question
I am new to VB and am trying to divide the contents of two list boxes. However every time I try it is coming up with errors such as; Argument 'Expression' cannot be converted to type 'ObjectCollection'. I have been changing around the code but have not since had any luck. I would be very appreciative to any help, thanks!
Dim pSmokers As Short
pSmokers = (Val(lstSmoker.Items)) / (Val(lstTotal.Items)) * 100
lstTotal.Items.Add(pSmokers)
Assuming that lstSmoker is listBox, you are not using it properly. This will not work
Val(lstSmoker.Items)
You need to do something like this
Short.Parse(lstSmoker.Items(0)) ' Where "0" is index of your item in listbox
Again, this is assuming your item in list control is string. So your code will looke like this:
pSmokers = Short.Parse(lstSmoker.Items(0)) / Short.Parse(lstTotal.Items(0)) * 100
Unfortunately I don't know how you keep data in your list. May be you want to have count of items in the list calculated rather than data. Then do this
pSmokers = lstSmoker.Items.Count / lstTotal.Items.Count * 100
!!! But now you running into problem that if pSmokers is short, you having a division here. Means, you will get decimal number. So, you need to change the data type of pSmokers
You also may run into division by "0" issue if there are no smokers. To prevent it do
If lstTotal.Items.Count > 0 Then
Dim pSmokers as Decimal = lstSmoker.Items.Count / lstTotal.Items.Count * 100
txtTotal.text= pSmokers.ToString("G")
End If
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
My chart contains some extraneous series. These series all contain the word "series" in them (e.g., "Series1", "Series2") rather than descriptive names.
Can someone please provide a VBA procedure that executes this Pseudocode:
In chart 1 if any series name contains the word "series" delete it.
If not then do nothing
Sub DeleteSeriesWith_Series_InName()
Dim iSrs As Long
With ActiveChart
For iSrs = .SeriesCollection.Count To 1 Step -1
If InStr(LCase$(.SeriesCollection(iSrs).Name), "series") > 0 Then
.SeriesCollection(iSrs).Delete
End If
Next
End With
End Sub
Count series backwards, because deleting a series changes the series numbers of any series after it.