|
Hello, Everyone, I am a newer with Visual Basic 2008. There is a question with me.
I have a Database Named: PasswordData.sdf, it has two tables in it, one is: TableDetail, another is TableUser. TableDetail have some IDs in it, for example: Customer Name, TableUser have three IDs in it: UserName, Password, UserType.
There are two Forms, one is Login Form, it have User Name TextBox, Password TextBox and UserType Textbox. The other is Main Form, it have Customer Name TextBox, Customer Sex TextBox, Customer Address TextBox and so on.
I want to write some codes with VB2008, but I don't know. Could you help me?
Thank you So much!
Jacky Shen
|
|
|
|
|
dzhello wrote: I want to write some codes with VB2008, but I don't know. Could you help me?
On the surface, this may sound like a stupid question, but write code to do WHAT?
|
|
|
|
|
MSDN: Development for beginners[^]
I would start looking at these articles / references to begin with
As barmey as a sack of badgers
Dude, if I knew what I was doing in life, I'd be rich, retired, dating a supermodel and laughing at the rest of you from the sidelines.
|
|
|
|
|
How do I code the price function for the prices of each checked boxes and radio buttons to show in the total label? I have decided that if no one is going to help me with this project, then I will drop the class with a W.
If anyone wants to see my graphical user interface, I will send it to you. Thank you for your help geniuses! I will say good things about you in heaven.
Public Class Form1
Private Sub exitButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles exitButton.Click
Me.Close()
End Sub
Private Sub newOrderButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles newOrderButton.Click
' clears all the information that is displayed and start over
nameTextBox.Text = String.Empty
addressTextBox.Text = String.Empty
telephoneTextBox.Text = String.Empty
viewCheckBox.Checked = False
bedCheckBox.Checked = False
jacuzziCheckBox.Checked = False
breakfastCheckBox.Checked = False
internetCheckBox.Checked = False
mattressCheckBox.Checked = False
sealyRadioButton.Checked = False
sertaRadioButton.Checked = False
simmonsRadioButton.Checked = False
regularRadioButton.Checked = False
executiveRadioButton.Checked = False
suiteRadioButton.Checked = False
cashRadioButton.Checked = False
visaTextBox.Text = String.Empty
visaTextBox.Enabled = False
visaRadioButton.Checked = False
mastercardTextBox.Text = String.Empty
mastercardTextBox.Enabled = False
mastercardRadioButton.Checked = False
checkTextBox.Text = String.Empty
checkTextBox.Enabled = False
checkRadioButton.Checked = False
nameTextBox.Focus()
End Sub
Private Sub orderButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles orderButton.Click
Dim regular As Double
Dim total As Double
Double.TryParse(regularRadioButton.Checked, regular)
If regularRadioButton.Checked Then
totalLabel.Text = total + 199.5
ElseIf executiveRadioButton.Checked Then
totalLabel.Text = total + 375.0
ElseIf suiteRadioButton.Checked Then
totalLabel.Text = total + 495.99
End If
If viewCheckBox.Checked Then
totalLabel.Text = total + 250.0
ElseIf bedCheckBox.Checked Then
totalLabel.Text = total + 70.0
ElseIf jacuzziCheckBox.Checked Then
totalLabel.Text = total + 199.0
ElseIf breakfastCheckBox.Checked Then
totalLabel.Text = total + 30.0
ElseIf internetCheckBox.Checked Then
totalLabel.Text = total + 19.99
ElseIf mattressCheckBox.Checked Then
totalLabel.Text = total + 55
totalLabel.Text = total + 45.0
totalLabel.Text = total + 35.0
End If
messageLabel.Text = "You have placed an order for" & ControlChars.NewLine & ControlChars.NewLine
If regularRadioButton.Checked Then
order = "Regular ($199.50)"
ElseIf executiveRadioButton.Checked Then
order = "Executive ($375.00)"
ElseIf suiteRadioButton.Checked Then
order = "Suite (495.99)"
End If
totalLabel.Text = total.ToString("C2")
End Sub
Private Sub cashRadioButton_CheckedChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cashRadioButton.CheckedChanged
If cashRadioButton.Checked Then
visaTextBox.Enabled = False
End If
If cashRadioButton.Checked Then
mastercardTextBox.Enabled = False
End If
If cashRadioButton.Checked Then
checkTextBox.Enabled = False
End If
If visaRadioButton.Checked Then
visaTextBox.Enabled = True
End If
If mastercardRadioButton.Checked Then
mastercardTextBox.Enabled = True
End If
If checkRadioButton.Checked Then
checkTextBox.Enabled = True
End If
End Sub
|
|
|
|
|
Inside orderButton_Click() the total isn't changing at all;
a sequence of statements such as totalLabel.Text = total + 19.99 is modifying what can be seen in the totalLabel label, it doesn't do anything to the total variable. And the GUI will only show the outcome of the last assignment to totalLabel.Text
What you should have is like so:
Dim total As Double = 0
If ... Then
total = total + 199.5
If ... Then
total = total + 370
...
totalLabel.Text = total.ToString("C2")
That way, the total variable starts at a known value (zero), and increases by accumulating the selected prices. Note how the totalLabel control is used only once, to display the result, when all calculations have finished.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
And replace the content of your cashRadioButton_CheckedChanged method with this one:
vistaTextBox.Enabled = visaRadioButton.Checked
mastercardTextBox.Enabled = mastercardRadioButton.Checked
checkTextBox.Enabled = checkRadioButton.Checked
So many If statements are really confusing for just enabling a control when its option is selected.
|
|
|
|
|
how can we generate data report in visual basic and hw can we have the print of it
|
|
|
|
|
This can be considered - http://www.vbtutor.net/vb6/lesson40.html[^].
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
|
|
|
|
|
|
I have a task that is being repeated throughout the application many times. My goal is to take those methods and consolidate it into a Global method.
The problem I am running into is that each task uses a different class type.
My thoughts were to create a method, say IncrementLine(), passing in as a parameter an Enum that would tell it what class it is coming from (Rooms or Library for instance).
This is an example of the existing code from one of these methods: (Also this is the exact code I need to change to bring back different classes, instead of RoomData it could be LibraryData - instead of Room it could be Library)
Dim lstRooms As List(Of RoomData) = Room.LoadAllForLibrary(libraryID)
The code for each of my methods that call IncrementLine() have their own classes like RoomData and Room. With the exception of the code above the rest of the method codes are identical.
Without using a bunch of Selects to determine what Class I should use..how can I return the proper class based on the enum passed in?
I was thinking of maybe using a Generic Delegate Class..something like this:
Public Function ReturnClass(Of t)(ByVal _lType As ListType) As t
End Function
based on what enum value they place it would send back the correct class..however, once I created this class I realized I'd still have to do a Select to determine what ListType they provided.
So my question is, how can I change the code above to be dynamic in returning the proper class based on the enum?
Thanks
|
|
|
|
|
sir;
i think that you need to use Type.GetConstructor() to return an instance of the appropriate type.
Good Luck;
Help people,so poeple can help you.
|
|
|
|
|
Another alternative would be using the Activator , as described here[^].
I are Troll
|
|
|
|
|
Good alternative, Sir.
100
Help people,so poeple can help you.
|
|
|
|
|
I agree great solution, thank you both for the time on this.
|
|
|
|
|
Hi all,
I have a database where the data contains some special chars.
I retrive the data from the dbase (dbf) file with a sql statement and write it into a text file using vb.net.
When I write the text file some of the special characters are not written the same way as in the dbf file, its written as a box.
I'm using:
<br />
Using sw As StreamWriter = New StreamWriter(dbfFile, False, System.Text.Encoding.Default)<br />
while writing to text file.
I'm not sure how to read the exact data from the database.
Is there a special way to do that???
Thanks in advance for anyh suggestion and help.
|
|
|
|
|
if you want to use characters outside the ASCII set, you need either a specific "code page" (not my recommendation) or 16-bit characters (Unicode).
what field type are you using in the database? it should be nvarchar or ntext in most databases for Unicode.
and then better specify Encoding.Unicode explicitly, both when writing to and reading from the database.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
he wrote about dbf (dbase) files ... no nvarchar, only fixed size char fields. in dbf files, the application has to take care of the correct codepage (you can nearly write everything in a dbf char field, except the 0 char).
I cannot remember: What did I before google?
|
|
|
|
|
The linefeed(LF) character is written as a box.
If i have a line feed, i want to ignore it...
ie; ignore only (LF) and not CRLF.
Thanks for any solution.
|
|
|
|
|
You have a solution to this - the ReplaceControlChars sub does this.
It also replaces chars such as tabs (i.e. any control char)
Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
The only valid measurement of code quality: WTFs/minute.
|
|
|
|
|
Hello David
Hope you are doing good.
Yes, I know that ReplaceControlChars sub does it, but, its a case where a description contains a LF in between 2 words.
And we found that its an error on the dbf file a line feed should not occur inbetween 2 words in a particular field(column), where as a blank space is allowed inbetween 2 words and once the LF is been removed, the application works fine.
Thanks a lot for the reply.
|
|
|
|
|
hi
how find window lock time and unlock time?
Private Sub Command1_Click()
Shell "rundll32.exe user32.dll,LockWorkStation", vbHide
End Sub
this coding using for locking the windows system.
but i need lock time(ctl+alt+del)
thks
|
|
|
|
|
|
Your code would have to be running on the machine already. Like the other reply stated, you'd have to register for notification of the lock. Windows does not track the lock and unlock times itself, so your code would have to record the times when they happen.
|
|
|
|
|
Hi;
Im using the code wrote by "Dennis Austin" in the link below
A New Task Scheduler Class Library for .NET[^]
Im tring to create new task but I faced an error said : "Object reference not set to an instance of an object".
at line :
t.ApplicationName = "chkdsk.exe";
The whole sub that im using :
//Get a ScheduledTasks object for the local computer.
ScheduledTasks st = new ScheduledTasks();
// Create a task
Task t;
try {
t = st.CreateTask("D checker");
} catch (ArgumentException) {
Console.WriteLine("Task name already exists");
return;
}
t.ApplicationName = "chkdsk.exe";
t.Parameters = "d: /f";
t.Comment = "Checks and fixes errors on D: drive";
t.SetAccountInformation(@"THEDOMAIN\TheUser", "HisPasswd");
t.IdleWaitMinutes = 10;
t.MaxRunTime = new TimeSpan(2, 30, 0);
t.Priority = System.Diagnostics.ProcessPriorityClass.Idle;
t.Triggers.Add(new WeeklyTrigger(6, 30, DaysOfTheWeek.Sunday));
t.Save();
t.Close();
st.Dispose();
Plz help;
|
|
|
|
|
Put your code in Code block
BTW which line throws the error Object reference not set to an instance of an object ? Put Trace in code & run & then tell us.
|
|
|
|