|
Well, just count how many entries you have, and once you have four, you drop one from the bottom when you add one at the top.
How do you store them ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hello,
I am new to visual basics and I am taking a class in it. I am trying to write a code for this and I am so confused on what to do. If anyone could help I would appreciate it.
Here is the question in my book:
Write a program that requests a complete phone number in a text box and then displays the area code in another text box when a button is pressed.
Thanks if you can help..
|
|
|
|
|
so... whrer you are stuck??
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
I am able to put the phone number in my text box, but when I push the button for it to extract only my area code it doesnt do anything. Here is my code:
Private Sub btnPush_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPush.Click
Dim txtPhone As Double
Dim xxx As Double
Dim xxxx As Double
Dim phone(11) As String
txtPhone = CDbl(xxx) & (xxx & xxxx)
phone(11) = CStr(xxx) & (xxx & xxxx)
phone(3) = CStr(xxx)
|
|
|
|
|
This is pretty strange code. How dod you expect it to extract anything ? It declares an double, does not assign a value, then does some things that will achieve nothing.
You need to use a regular expression, or the string methods that extract substrings.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Forgive me, but I know that otherwise I wouldnt be writting in to this forum.
I changed it to this: this is better but it still is only giving me "xxx" instead of the input of the phone number:
Private Sub btnPush_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnPush.Click
Dim txtPhone As String
Dim phone(11) As String
txtPhone = CStr("xxx - xxx - xxxx")
phone(11) = CStr("xxx - xxx - xxxx")
phone(3) = CStr("xxx")
btnPush.ToString.Substring(0, 3)
txtArea.Text = ("xxx")
|
|
|
|
|
buzz5958 wrote: Dim txtPhone As String
Dim phone(11) As String
txtPhone = CStr("xxx - xxx - xxxx")
phone(11) = CStr("xxx - xxx - xxxx")
phone(3) = CStr("xxx")
This code is useless. Get rid of it. why do you need an array of strings ?
buzz5958 wrote: btnPush.ToString.Substring(0, 3)
This code gets a string from a button ( presumably 'Button' ) and returns a substring ( presumably 'But' ).
buzz5958 wrote: txtArea.Text = ("xxx")
The brackets in this code are superfluous, and this code sets the area code to be three x's.
It seems to me that you're wildly guessing, which is both not going to work, and not going to teach you anything if it manages to. You've got the substring method, so what do you want to get the substring of ? I assume you have a control which contains the phone number ( txtPhone is a good name for this control ). It has a Text property. This gives you the entered string. If you're allowed to assume a very specific input format, then the Substring method, on the text property of this control, will return the area code.
In future, I recommend you read through your textbooks and try to understand the process, instead of making wild guesses.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: txtPhone = CStr("xxx - xxx - xxxx")
phone(11) = CStr("xxx - xxx - xxxx")
phone(3) = CStr("xxx")
This code is useless
Yep. Why do arrays of strings?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Christian Graus wrote: use a regular expression
Sounds like the OP is pretty new to this stuff and that would be too much for him.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Yes, I mentioned it only for completeness.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: mentioned it only for completeness
I'll admit that I would have done the same
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Well, at that point, I was keen to give a full answer, he may well have said 'Oh, regex, yeah, I googled that and found Expresso and it helped me build what I needed'. that doesn't seem so possible, now....
When I was first learning, I'd have made a note that regex was a better solution, gone with what got me through the day, bought a book on regex and learned it.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Yes, I am sorry but I am new to all of this and the string thing just doesnt make since to me at all. I just thought that I might get some help to understand. I am taking an introduction to programming using Visual Basic 2005 and I am only in my 3rd week of the class. I did read the chapter, I just don't understand. Maybe I am trying to over think the process.
Thanks for all of your help,
Alexia
|
|
|
|
|
buzz5958 wrote: Maybe I am trying to over think the process.
Hey, it happens to all of us (well, those of us who will admit it). If you know that the area code is in a standard format such as (xxx) xxx-xxxx, you can always use the SubString method to pick out the area code. Once you have mastered working with strings, look at regular expressions as Christian said. They are really powerful and advanced
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Well, first of all how are phone numbers formatted where you are?
For example:
(020) 1234 5678
(0141) 123 4567
(01383) 123 456
Next what methods on the string class could you use to extract that area code? (Hint: you will be looking for something to find the position of certain characters and you will be looking for something to get a partial string from the original)
|
|
|
|
|
Hello all!
*VS2005 Datagrid
Here's what ive noticed on datagrid's vertical scrollbar behaviour,
1. The vertical scroll will not scroll between rows based on position of the scroll but instead based on rows. Moving the vertical scroll up/down will not matter much unless you have moved the scroll bar just enough so that the next/previous row can completely be seen.
Thus to programmatically change the vertical scrollbar's position, you can set as such;
<br />
dataGrid.FirstDisplayedScrollingRowIndex = x<br />
Now, i'm wondering why wouldnt the scrollbar be used to view something just like how any other scroll does where its based on scrollbar's position? And yes the weird thing is, the datagrid's horizontal scroll bar works normally.
Is there any way that I could change the datagrid's vertical scrollbar to display its content just as how the horizontal scroll would?
Thanks in advance!
Regards,
Jensen
|
|
|
|
|
Private Sub Print_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Print.Click
PrintDialog1.Document = PrintDocument1
PrintDialog1.PrinterSettings = PrintDocument1.PrinterSettings
PrintDialog1.AllowSomePages = True
If PrintDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
PrintDocument1.PrinterSettings = PrintDialog1.PrinterSettings
PrintDocument1.Print() 'this is the line where its showing the
error:uable to handle event.win32 exception
End If
PrintPreviewDialog1.Document = PrintDocument1
PrintPreviewDialog1.ShowDialog()
End Sub
what should i do.i m getting printer settings page but when i click print i am getting that error.plz mail me at niteshaga@gmail.com
|
|
|
|
|
You should not put your email address in a post, you'll open yourself up to spammers. If someone can help you, they'll tell you right here.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hello all developers,
am developing small project using vb.net with sql server, that project was completed successfully also am created the exe it was working nice with oter system also, but now i want to create a webapllication out put for the same project? that is like to open it in IE in any other ssytems in the network. Is it possible? if Possible then How to do it? Please explain..............
Note: am create a vb.net Project, code begin is VB, Connection is ODBC using SQL Client
|
|
|
|
|
rrrriiizz wrote: but now i want to create a webapllication out put for the same project?
Create a new Web Forms project. The code would be exectued on your IIS server, not on the client. You're really just creating a website.
At least I'm assuming you're talking about writing a web-based application and not a web-based installer to install your Windows Forms application on the client machine.
-- modified at 9:24 Saturday 8th September, 2007
|
|
|
|
|
how to change the size of font of textbox in vb.net using code
|
|
|
|
|
Salaam Alaikom
you can change the font size by doing this code
let us say that your textbox is called "txtValue"
then u do this id you want the size be 20 for example
txtValue.Font=New Font(txtValue.Font.Name,20)
regards
Hadi Hassan
Lebanon,Beirut
hadi.84@hotmail.com
|
|
|
|
|
You can use the following sample codes also
Dim new_font As Font
new_font = New Font(TextBox1.Font.Size, 30)
TextBox1.Font = new_font
|
|
|
|
|
Load the document into Word, search for your field tags and replace each with a Word field.
I have no idea what the code to add the field would be since I don't do Office Interop in my work.
But that's how you would do it.
|
|
|
|
|
Thanks a lot
Thanks
Terry
|
|
|
|