Author Archive

How to search through array in Visual Basic?

Wednesday, April 25th, 2012

In my program I have an array that contains the results of the rolls of a die. The user input how many times they wanted it rolled. I need to search through that array to find how many times a certain number shows up (also one that the user chose) to find it’s probability.

So I’d like a loop (or something else, but a loops is the only thing I can think of) to be able to loop through the array and keep track of how many times it shows up. I was going to use UBound and LBound, but because I’m finding the probability in a different procedure it won’t work.

Here’s what I have

Public Class Form1
Dim intTosses As Integer
Dim ResultTosses() As Integer
Dim intFindProb As Integer ‘This is the number that the user wants to see the probability for

Private Sub txtNumTosses_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtNumTosses.TextChanged
Dim intcounter As Integer
Dim intResult As Integer
intTosses = Val(txtNumTosses.Text)
ReDim ResultTosses(intTosses)

For intcounter = 1 To intTosses
intResult = Int(6 * Rnd(1) + 1)
ResultTosses(intcounter) = intResult
Next
lblProbability.Text = ResultTosses(intTosses)

End Sub

Private Sub txtNumProbability_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtNumProbability.TextChanged
Dim intpcounter As Integer
intFindProb = (Val(txtNumProbability.Text)
‘****Here is where I need to find out how many of intFindProb are in my ResultTosses Array****
If

Next
End Sub
End Class

If you could give a different example or just explain it that would be good, as it is something I need to pass in so I would like to put it together myself (we are allowed to ask for help, but the teacher is always busy), but I’m fairly lost so I’ll take what I can get.

The following code will allow the user to enter the number of rolls for one die that he wants to place in an array; and the two search numbers he desires to see howmany times they appear in the array. The number of occurrances for the two search numbers will appear in labels 1 and 2. You can use these 2 numbers for any purpose.

There is a button, 3 text boxes and 2 labels on my form.

Public Class Form1

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim HowMany As Integer
Dim Array(500) As Integer
Dim MaxIndex As Integer
Dim SearchNum1 As Integer = Val(TextBox2.Text)
Dim SearchNum2 As Integer = Val(TextBox3.Text)
Dim SearchNum1Cnt, SearchNum2Cnt As Integer
If IsNumeric(TextBox1.Text) Then
HowMany = Val(TextBox1.Text)
MaxIndex = HowMany – 1
End If
Dim Rnd As New Random
For i = 0 To MaxIndex
Array(i) = Rnd.Next(1, 7)
Next
For i = 0 To MaxIndex
‘MsgBox(i & " " & Array(i) & " " & SearchNum1)
If Array(i) = SearchNum1 Then
SearchNum1Cnt += 1
End If
If Val(Array(i)) = SearchNum2 Then
SearchNum2Cnt += 1
End If
Next
Label1.Text = SearchNum1Cnt
Label2.Text = SearchNum2Cnt
End Sub

End Class

Before using Excel’s advanced filtering capabilities, what must you do first?

Wednesday, April 25th, 2012

A) Define a criteria range

B) Setup your relational operators

C) Define a range for the filtered data?

i think its c
i am not sure what b means and theres stuff you can do before you do a

I want to develop strong skills in computer programming, specifically within…?

Wednesday, April 25th, 2012

- Excel VBA and Macros
- Web Design

Which programming languages do I need to learn, and what is the best way of going about learning these items in your opinion? Take classes? Read books? Online courses? I know it will take quite a while to develop a strong understanding about these topics – but what is the best way to learn?

Thanks.

They have computer programming books and courses at http://www.touchtextbooks.com

best way to learn excel?

Wednesday, April 25th, 2012


I found the best way to learn Excel or any software program, for that matter, is to purchase a textbook. The best ones I have found for Excel are the Shelley Cashman series. They explain everything and they have a picture to show you what your page should look like. There are other book series such as "Simply Visual". These can be found in school bookstores, but a cheaper source might be Amazon.com (they will lead you to good second hand resources), Powells.com, to name two. If you spend more than $25, shipping is free and in Oregon there is no sales tax.

How to write a VBA/Excel stopwatch?

Wednesday, April 25th, 2012

I need a stopwatch for a an excel userform I will be using. I need the stop watch to use the format "mm:ss" and start/reset with the same button. I am new to VBA, and do not know how to do this, can anyone provide me a solution?

You can’t do that for the device since there is no such feature available…

Good luck!

How can I use VBA in Excel to look up words in the ‘Word’ dictionary/thesaurus?

Wednesday, April 25th, 2012

I am experimenting with language parsing in Excel. I would like to use the dictionary and/or thesaurus in Word to look up definitions/synonyms for words that I have in my spreadsheet. I know that I can reference Word objects from VBA. Can anyone point me to some code that would help me do this please?

In Excel 2010, just hit F7 (like you can do in Word, etc) – that will launch the same spell checker. No additional code required.

when do you use Vlookup and Hlookup ?

Wednesday, April 25th, 2012

concise well explained answer please !
NEAR its not concise

http://www.howtogeek.com/howto/13780/using-vlookup-in-excel/

How to create VLOOKUP formula in excel?

Wednesday, April 25th, 2012

What is the most simple way to create a VLOOKUP formula in MS Excel?

the best way is to type =vlookup in the cell (in excel) then it will guide to fill the informtion needed. or click on fx button the wizerd will guide you. click on help in it, the help file will show you some example and explain the concept for you if you don’t know how does it work.

What is the best book to buy for learning advance Excel functions like pivot tables, vlookups, macros, etc?

Wednesday, April 25th, 2012

I need to learn these functions and more to become an inventory analyst.

I wouldn’t say that there is one book that covers everything. The closest to that would likely be the Excel (version of Excel) Inside Out book series. If you want to get the down and dirty basics quickly then the Plain & Simple series of books is great. John Walkenbach’s Excel Bible would probably be the next closest for covering everything besides Microsofts Inside Out series.

For macros, John Walkenbach’s book series Excel Power Programming with VBA is the best to easily understand. He also has some good books focused on just pivot tables or just Excel functions or just charts.

If you really want to understand these topics well, you’re likely talking multiple books, not just 1. The cover-all books do a pretty descent job covering most topics, but only just barely delve into macros, just enough to do something very very simple. You really need a book devoted primarily to VBA and macros to understand macros well.

The help from the Object Browser in the Visual Basic Editor is also really good to study to learn VBA. But you’ll understand that a lot better once you’ve programmed macros a descent bit.

Excel macro emploi du temps

Monday, April 23rd, 2012

Niveau débutant: Ce tutoriel explique comment créer une macro simple. D’autres vidéos sur agi67.fr.

Duration : 0:3:12

(more…)

Technorati Tags: , ,