|
My input text from a .txt file is
this is the first line
this is the second line
this is the third line
I need to capitalize the first letter of each word by placing it in a textbox, I have the following code:
Dim aString As String = My.Computer.FileSystem.ReadAllText("input.txt")
Dim stringReturn As String
If My.Computer.FileSystem.FileExists("input.txt") Then
Me.xInputTextBox.Text = (Convert.ToString(aString.ToLower))
End If
Do While (aString.IndexOf(Space(2)) >= 0)
aString = aString.Replace(Space(2), Space(1))
Loop
Dim caparray() As String = (aString.Split(" " & "ControlChars.NewLine"))
For I As Integer = 0 To caparray.Length - 1
If caparray(I).Length = 1 Then
caparray(I) = caparray(I).ToUpper
Else ' ***join them back together
caparray(I) = caparray(I).Substring(0, 1).ToUpper & caparray(I).Substring(1).ToLower
End If
Next
stringReturn = String.Join(" ", caparray)
Me.xInputTextBox.Text = (stringReturn.ToString)
My output is then
This Is The First Line
this Is The Second Line
this Is The Third Line
It will not capitalize the first letter of the second and third line. Can someone please tell me what I am doing wrong?
Thanks, Jesi
|
|
|
|
|
JessicaD523 wrote: This Is The First Line
this Is The Second Line
There is a newline but no space between Line and this, so to your algorithm they are
just one word! A simple debug session would have told you that.
You will have similar problems with punctuation: "aha" will be seen as a word starting
with " not a.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thank you, I kind of thought that was the problem...but how do i fix that? I'm very new at vb.net. Thanks.
Jesi
|
|
|
|
|
Hi Jesi,
JessicaD523 wrote: but how do i fix that?
as always:
1. define the requirements as accurately as possible (what is a word, which
words need capitalization, ...)
2. analyze, design, implement, test
3. iterate until satisfied.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
stringReturn = String.Join(" ", caparray)
I do not have your answer but what does this String.Join do, is it joining the first line to the second line and so on?
Can you use vbcrlf to go to the next line or 'proper case' instead of 'upper case'.
|
|
|
|
|
How do i call Other programs like office and Excel , Outlook From my VB App
|
|
|
|
|
The esiest way to launch any external application or file is to use Start method of System.Diagnostics.Process class.
Following line may be used to start MS Word application –
System.Diagnostics.Process.Start("C:\Program Files\Microsoft Office\OFFICE11\winword.exe")
You should change the path of winword.exe according to your installation folder.
I hope this helps .
-Dave.
Dave Traister,
ComponentOne LLC.
www.componentone.com
|
|
|
|
|
Hi,
I am using VB in MS ACCESS and is not able to update a date field in the database, I am taking the value from a textbox in the form.
This is the query I have been using...
s = "Update Table1 set DOB = """ + Text2.Value + """ where name = """ + Text0.Value + """ "
DoCmd.RunSQL (s)
It is showing the type mismatch error.
Can somebody please help me with this.
Thanks
|
|
|
|
|
A date in Access is written between # characters, not quotation marks.
A string in SQL is written between apostrophes ('), not quotation marks.
You should read up on SQL injection. Your code is wide open for SQL injection attacks.
---
"Anything that is in the world when you're born is normal and ordinary and is just a natural part of the way the world works. Anything that's invented between when you're fifteen and thirty-five is new and exciting and revolutionary and you can probably get a career in it. Anything invented after you're thirty-five is against the natural order of things."
-- Douglas Adams
|
|
|
|
|
Hi ,
I am writing a datatable to xml file , i am using xmlwriter in vb.net to write .I am setting the prefix by writing the namespace using these things
xw.WriteStartElement("Name")<br />
xw.WriteStartAttribute("fn",nothing, "c:/Font.xsd")<br />
xw.WriteStartAttribute("txt", "Text", "c:/Text.xsd") so that i can use the prefix in the program while using <br />
xw.WriteStartElement("txt", "TextBackColor", Nothing)<br />
xw.WriteString(dtTextBox.Rows(iTextBoxesCount).Item("BackColor").ToString())<br />
xw.WriteEndElement()
i am getting the output like this on top of xml page
<Name <big>fn="" lbl:Label="" txt:Text="" pos:Position="" xs=""</big> xmlns:xs="http://www.w3.org/2001/schema-instance" xmlns:pos="c:\Position.xsd" xmlns:txt="c:\Text.xsd" xmlns:lbl="c:\Label.xsd" xmlns:fn="c:\Font.xsd">
Now the thing i dont want these things highlighted in bold .This is the exta information .How to remove these things ??
Thanks,
Dvs
|
|
|
|
|
I am trying to develop a application using vb.net. printer connected with server also it shared with all their clients. now my application exactly find the printer status like how many print made by particular system. examble if i give 10 copy print from system1 and 5 copies from system2, my application in server system store this information like
system1 - 10 copies - date & time
system2 - 5 copies - date & time
( pear to pear network )
please any one help me
|
|
|
|
|
|
Hi
I am writing a datatable to xml file ,so in the meanwhile i wanted touse the .xsd file to validate the xml format. how to use . presently , i am using xmlwriter to write .In that i am uisng writestartelement(string ,namespace,) ,writeAttribute,etc . I am writing in it but how toknow whether it is correct or not . I want to set the prefix also .I used the namespace on the top ,but how to use in vb.net to get done like this .I am getting without this txt:, fn:. I have to generate from xsd .
i want like this , i am looping my datatable .How to set fn,txt
<code> <txt:TextBox TextIndex="1">
<txt:TextName>Text1</txt:TextName>
<txt:TextAlign>0</txt:TextAlign>
<txt:Appearance>1</txt:Appearance>
<txt:TextBackColor>-2147483643</txt:TextBackColor>
<txt:TextForeColor>-2147483640</txt:TextForeColor>
<txt:TextBorderStyle>1</txt:TextBorderStyle>
<txt:TextText>Text1</txt:TextText>
- <fn:Font></code>
I am new to this topic .
Any references for that or suggestions
Dvs
-- modified at 6:41 Saturday 20th October, 2007
|
|
|
|
|
I want to develop an windows application that will retrieve emails from my gmail's account.
I am trying to do it using socket class as follows -
TCP = New Net.Sockets.TcpClient
TCP.Connect("pop.gmail.com", 995)
but after this I didn't get any response.
So how to retrieve mail ?
|
|
|
|
|
You say no response, but fail to identify what no response means.
Did pop.gmail.com fail to resolve to an ip, did the server reject your connection or did you successfully connect and authenticate a pop3sl connection?
Have you implemented your pop3 sl client correctly according to RFC 1939, 2449 and 2595 (not sure if any others apply now)?
A little more detail may elicit more of a response from the community.
I'm largely language agnostic
After a while they all bug me
|
|
|
|
|
hi everyone, i am trying to do this and i need some serious help on this, i need to develope an "Technology Conference Registration" small program for my intro to visual basic class.
here is the info i recieved from my professor:
Technology Conference Registration
DIMC has requested that you develope a mobile application that can determine and display the total cost per company for developers attending the conference. DIMC has a conference policy that states if any member of a company has attended a previous DIMC conference, the company recieves a 15% discount from the total coast of its employess who attend. The policy also states that no more than 16 people from a single company can attend the conference. DIMC has asked that you design the program so that the user must enter valid data.
number of conference registration Cost per Attendee
per company
1 $695
2-4 $545
5-8 $480
8 or more $395
that is in my book this isn't for a real company but that is what i need help with i really need help with some coding, anyone think they can help me?
/J-Man\
|
|
|
|
|
Have you tried to do this yourself? People here will be willing to help you if you get stuck with specific problems, but no one is going to do your work for you.
The problem seems to be pretty well stated and should provide you with enough information to list the requirements. Once you list out the requirements, think about what you need to do in order to accomplish each requirement.
I will give you a few pointers...you will need some sort of database in order to keep track of who has previously attended a conference and the actual conference registrations. You will also need the front-end application. Even though the problem specifically says it must be a mobile device, don't let that limit how you would design the solution from a "big picture" standpoint. The high-level requirements will be the same no matter what, and the underlying architecture will be pretty much the same as well. The biggest impact it will have will be on the choice of user interface controls and layout.
|
|
|
|
|
well the thing is, i really have no idea how to do this. I don't even no were to start. I just started and our professor got pissed and assigned this to our class because of everyone having trouble, i no she said not to use a database and to just "think about it and you'll get it"
but thanks anyway,
Jesse
P.S. What should be the first thing i try?
/J-Man\
|
|
|
|
|
using ErrorProvider in VB HELP!!
My problem is the errorProvider show but it doesn't stay visible? it is just visible for a split of second after the MSGBOX has been click OK then after that? it seems it automatically dispose or hide itself that it wasn't mean to be???
I don't know why?? Please anyone with a kind heart to help me with this difficulties of mine?? please be patience about my bit of ignorance with this control i've just used this control for the first time.. ehehe.. ERRORPROVIDER in VB...
**************
Sub OnErrorMessage(ByVal controlOnError As Control, _
ByVal errorMessage As String)
ErrorProvider.SetError(controlOnError, errorMessage)
MsgBox(errorMessage, MsgBoxStyle.Exclamation)
controlOnError.Focus()
End Sub
Function DataFieldValidation() As Boolean
Dim valid As Boolean = True
Try
If String.IsNullOrEmpty(txtboxLastname.Text) Then
OnErrorMessage(txtboxLastname, _
"LastName TextField is required and could not be empty..")
valid = False
Exit Try
End If
Catch ex As Exception
MsgBox(ex.ToString())
End Try
Return valid
End Function
Friend Sub UpdateRecord()
Try
Me.Cursor = Cursors.WaitCursor
If DataFieldValidation() = False Then
Me.Cursor = Cursors.Default
Exit Sub
End If
' i've ommitted other database transaction codes here
' to minimize this post
Me.Cursor = Cursors.Default
Catch ex As Exception
MsgBox(ex.ToString())
End Try
End sub
**************
advance thank you so much to any reply.. please...
-- modified at 22:21 Friday 19th October, 2007
|
|
|
|
|
Hey all, I'm having trouble creating a program that lets two players play a game of tic tac toe. I'm not sure exactly how to let my winSub figure out which boxes make up the winning combination (of three of the same characters in a row)
Here's part of my code:
Private Sub btnCheck_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCheck.Click
'checks if winner exists
Dim strBox1, strBox2, strBox3 As String
If txtTL.Text = txtTM.Text And txtTM.Text = txtTR.Text And txtTL.Text <> "" Then
strBox1 = txtTL.Text
strBox2 = txtTM.Text
strBox3 = txtTR.Text
Call subWin(strBox1, strBox2, strBox3, txtTL.Text)
ElseIf txtTR.Text = txtMM.Text And txtMM.Text = txtBL.Text And txtTL.Text <> "" Then
strBox1 = txtTR.Text
strBox2 = txtMM.Text
strBox3 = txtBL.Text
Call subWin(strBox1, strBox2, strBox3, txtTR.Text)
End If
End Sub
Private Sub subWin(ByVal strBoxOne As String, ByVal strBoxTwo As String, ByVal strBoxThree As String, ByVal strWinner As String)
'this will be called when the program sees a winner
lblResult.Text = ("The winner is " & strWinner)
Select Case strBoxOne
Case "TL"
txtTL.BackColor = Color.Blue
Case "TM"
txtTM.BackColor = Color.Blue
Case "TR"
txtTR.BackColor = Color.Blue
Case "ML"
txtML.BackColor = Color.Blue
Case "MM"
txtMM.BackColor = Color.Blue
Case "MR"
txtMR.BackColor = Color.Blue
Case "BL"
txtBL.BackColor = Color.Blue
Case "BM"
txtBM.BackColor = Color.Blue
Case "BR"
txtBR.BackColor = Color.Blue
End Select
Any help would be greatly appreciated.
|
|
|
|
|
Hi,
without arrays, you will need a lot of code since there are 8 positions where you
can have a win (3 rows, 3 cols, 2 diags).
I would suggest a single, linear, array layed out like this:
0 1 2
3 4 5
6 7 8
containing say integers (0=empty, 1=player 1, 2=player 2)
Note: or characters (' '=empty, 'X'=player 1, 'O'=player 2)
Then recognizing a win after player N moved(=1 or 2, or 'X'/'O'), is looking
for three values N at three array positions with
start index = 0 3 6 0 1 2 0 2
index incr = 1 1 1 3 3 3 4 2
which themselves can also be kept in two arrays,
hence a simple for loop over these 8 possibilities would do it.
Note that I separate the GUI parts (textboxes, whatever) from the game logic!
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Hi this is the complite project so just copy and past in to ur project
good luck
take care
*********************************************
Option Explicit On
Option Strict On
Public Class frmTicTacToe
Inherits System.Windows.Forms.Form
#Region " Windows Form Designer generated code "
Public Sub New()
MyBase.New()
'This call is required by the Windows Form Designer.
InitializeComponent()
'Add any initialization after the InitializeComponent() call
End Sub
'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer
'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents Label3 As System.Windows.Forms.Label
Friend WithEvents Label4 As System.Windows.Forms.Label
Friend WithEvents Label5 As System.Windows.Forms.Label
Friend WithEvents picMark1 As System.Windows.Forms.PictureBox
Friend WithEvents picMark2 As System.Windows.Forms.PictureBox
Friend WithEvents picTurn As System.Windows.Forms.PictureBox
Friend WithEvents picMark3 As System.Windows.Forms.PictureBox
Friend WithEvents picMark4 As System.Windows.Forms.PictureBox
Friend WithEvents picMark5 As System.Windows.Forms.PictureBox
Friend WithEvents picMark6 As System.Windows.Forms.PictureBox
Friend WithEvents picMark7 As System.Windows.Forms.PictureBox
Friend WithEvents picMark8 As System.Windows.Forms.PictureBox
Friend WithEvents picMark9 As System.Windows.Forms.PictureBox
Friend WithEvents picEarth As System.Windows.Forms.PictureBox
Friend WithEvents picSun As System.Windows.Forms.PictureBox
Friend WithEvents btnReset As System.Windows.Forms.Button
Friend WithEvents lblTurn As System.Windows.Forms.Label
Friend WithEvents btnExit As System.Windows.Forms.Button
Friend WithEvents picTie As System.Windows.Forms.PictureBox
Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu
Friend WithEvents mnuFile As System.Windows.Forms.MenuItem
Friend WithEvents mnuFileNew As System.Windows.Forms.MenuItem
Friend WithEvents mnuFileTotal As System.Windows.Forms.MenuItem
Friend WithEvents mnuFileBar As System.Windows.Forms.MenuItem
Friend WithEvents mnuFileExit As System.Windows.Forms.MenuItem
Friend WithEvents mnuHelp As System.Windows.Forms.MenuItem
Friend WithEvents mnuHelpAbout As System.Windows.Forms.MenuItem
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(frmTicTacToe))
Me.lblTurn = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.Label3 = New System.Windows.Forms.Label
Me.Label4 = New System.Windows.Forms.Label
Me.Label5 = New System.Windows.Forms.Label
Me.picMark1 = New System.Windows.Forms.PictureBox
Me.picMark2 = New System.Windows.Forms.PictureBox
Me.picMark3 = New System.Windows.Forms.PictureBox
Me.picMark4 = New System.Windows.Forms.PictureBox
Me.picMark5 = New System.Windows.Forms.PictureBox
Me.picMark6 = New System.Windows.Forms.PictureBox
Me.picMark7 = New System.Windows.Forms.PictureBox
Me.picMark8 = New System.Windows.Forms.PictureBox
Me.picMark9 = New System.Windows.Forms.PictureBox
Me.btnReset = New System.Windows.Forms.Button
Me.picEarth = New System.Windows.Forms.PictureBox
Me.picSun = New System.Windows.Forms.PictureBox
Me.picTurn = New System.Windows.Forms.PictureBox
Me.btnExit = New System.Windows.Forms.Button
Me.picTie = New System.Windows.Forms.PictureBox
Me.MainMenu1 = New System.Windows.Forms.MainMenu
Me.mnuFile = New System.Windows.Forms.MenuItem
Me.mnuFileNew = New System.Windows.Forms.MenuItem
Me.mnuFileTotal = New System.Windows.Forms.MenuItem
Me.mnuFileBar = New System.Windows.Forms.MenuItem
Me.mnuFileExit = New System.Windows.Forms.MenuItem
Me.mnuHelp = New System.Windows.Forms.MenuItem
Me.mnuHelpAbout = New System.Windows.Forms.MenuItem
Me.SuspendLayout()
'
'lblTurn
'
Me.lblTurn.Font = New System.Drawing.Font("Microsoft Sans Serif", 18.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte))
Me.lblTurn.Location = New System.Drawing.Point(200, 16)
Me.lblTurn.Name = "lblTurn"
Me.lblTurn.Size = New System.Drawing.Size(104, 32)
Me.lblTurn.TabIndex = 0
Me.lblTurn.Text = "Turn"
Me.lblTurn.TextAlign = System.Drawing.ContentAlignment.MiddleCenter
'
'Label2
'
Me.Label2.BackColor = System.Drawing.Color.Blue
Me.Label2.Location = New System.Drawing.Point(160, 80)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(8, 440)
Me.Label2.TabIndex = 1
'
'Label3
'
Me.Label3.BackColor = System.Drawing.Color.Blue
Me.Label3.Location = New System.Drawing.Point(336, 80)
Me.Label3.Name = "Label3"
Me.Label3.Size = New System.Drawing.Size(8, 440)
Me.Label3.TabIndex = 2
'
'Label4
'
Me.Label4.BackColor = System.Drawing.Color.Blue
Me.Label4.Location = New System.Drawing.Point(8, 216)
Me.Label4.Name = "Label4"
Me.Label4.Size = New System.Drawing.Size(496, 8)
Me.Label4.TabIndex = 3
'
'Label5
'
Me.Label5.BackColor = System.Drawing.Color.Blue
Me.Label5.Location = New System.Drawing.Point(8, 376)
Me.Label5.Name = "Label5"
Me.Label5.Size = New System.Drawing.Size(496, 8)
Me.Label5.TabIndex = 4
'
'picMark1
'
Me.picMark1.Location = New System.Drawing.Point(40, 96)
Me.picMark1.Name = "picMark1"
Me.picMark1.Size = New System.Drawing.Size(90, 90)
Me.picMark1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.picMark1.TabIndex = 5
Me.picMark1.TabStop = False
'
'picMark2
'
Me.picMark2.Location = New System.Drawing.Point(208, 96)
Me.picMark2.Name = "picMark2"
Me.picMark2.Size = New System.Drawing.Size(90, 90)
Me.picMark2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.picMark2.TabIndex = 6
Me.picMark2.TabStop = False
'
'picMark3
'
Me.picMark3.Location = New System.Drawing.Point(384, 96)
Me.picMark3.Name = "picMark3"
Me.picMark3.Size = New System.Drawing.Size(90, 90)
Me.picMark3.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.picMark3.TabIndex = 7
Me.picMark3.TabStop = False
'
'picMark4
'
Me.picMark4.Location = New System.Drawing.Point(40, 256)
Me.picMark4.Name = "picMark4"
Me.picMark4.Size = New System.Drawing.Size(90, 90)
Me.picMark4.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.picMark4.TabIndex = 8
Me.picMark4.TabStop = False
'
'picMark5
'
Me.picMark5.Location = New System.Drawing.Point(208, 256)
Me.picMark5.Name = "picMark5"
Me.picMark5.Size = New System.Drawing.Size(90, 90)
Me.picMark5.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.picMark5.TabIndex = 9
Me.picMark5.TabStop = False
'
'picMark6
'
Me.picMark6.Location = New System.Drawing.Point(384, 256)
Me.picMark6.Name = "picMark6"
Me.picMark6.Size = New System.Drawing.Size(90, 90)
Me.picMark6.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.picMark6.TabIndex = 10
Me.picMark6.TabStop = False
'
'picMark7
'
Me.picMark7.Location = New System.Drawing.Point(40, 408)
Me.picMark7.Name = "picMark7"
Me.picMark7.Size = New System.Drawing.Size(90, 90)
Me.picMark7.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.picMark7.TabIndex = 11
Me.picMark7.TabStop = False
'
'picMark8
'
Me.picMark8.Location = New System.Drawing.Point(208, 408)
Me.picMark8.Name = "picMark8"
Me.picMark8.Size = New System.Drawing.Size(90, 90)
Me.picMark8.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.picMark8.TabIndex = 12
Me.picMark8.TabStop = False
'
'picMark9
'
Me.picMark9.Location = New System.Drawing.Point(384, 408)
Me.picMark9.Name = "picMark9"
Me.picMark9.Size = New System.Drawing.Size(90, 90)
Me.picMark9.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.picMark9.TabIndex = 13
Me.picMark9.TabStop = False
'
'btnReset
'
Me.btnReset.Location = New System.Drawing.Point(200, 560)
Me.btnReset.Name = "btnReset"
Me.btnReset.Size = New System.Drawing.Size(104, 23)
Me.btnReset.TabIndex = 14
Me.btnReset.Text = "&Reset Game"
'
'picEarth
'
Me.picEarth.Image = CType(resources.GetObject("picEarth.Image"), System.Drawing.Image)
Me.picEarth.Location = New System.Drawing.Point(56, 536)
Me.picEarth.Name = "picEarth"
Me.picEarth.Size = New System.Drawing.Size(60, 60)
Me.picEarth.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.picEarth.TabIndex = 15
Me.picEarth.TabStop = False
Me.picEarth.Visible = False
'
'picSun
'
Me.picSun.BackColor = System.Drawing.Color.Silver
Me.picSun.Image = CType(resources.GetObject("picSun.Image"), System.Drawing.Image)
Me.picSun.Location = New System.Drawing.Point(400, 536)
Me.picSun.Name = "picSun"
Me.picSun.Size = New System.Drawing.Size(60, 56)
Me.picSun.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.picSun.TabIndex = 16
Me.picSun.TabStop = False
Me.picSun.Visible = False
'
'picTurn
'
Me.picTurn.Location = New System.Drawing.Point(136, 8)
Me.picTurn.Name = "picTurn"
Me.picTurn.Size = New System.Drawing.Size(50, 50)
Me.picTurn.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.picTurn.TabIndex = 17
Me.picTurn.TabStop = False
'
'btnExit
'
Me.btnExit.Location = New System.Drawing.Point(392, 24)
Me.btnExit.Name = "btnExit"
Me.btnExit.TabIndex = 18
Me.btnExit.Text = "&Exit Game"
'
'picTie
'
Me.picTie.Image = CType(resources.GetObject("picTie.Image"), System.Drawing.Image)
Me.picTie.Location = New System.Drawing.Point(8, 8)
Me.picTie.Name = "picTie"
Me.picTie.Size = New System.Drawing.Size(50, 50)
Me.picTie.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
Me.picTie.TabIndex = 19
Me.picTie.TabStop = False
Me.picTie.Visible = False
'
'MainMenu1
'
Me.MainMenu1.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuFile, Me.mnuHelp})
'
'mnuFile
'
Me.mnuFile.Index = 0
Me.mnuFile.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuFileNew, Me.mnuFileTotal, Me.mnuFileBar, Me.mnuFileExit})
Me.mnuFile.Text = "&File"
'
'mnuFileNew
'
Me.mnuFileNew.Index = 0
Me.mnuFileNew.Shortcut = System.Windows.Forms.Shortcut.CtrlN
Me.mnuFileNew.Text = "&New Game"
'
'mnuFileTotal
'
Me.mnuFileTotal.Index = 1
Me.mnuFileTotal.Shortcut = System.Windows.Forms.Shortcut.CtrlT
Me.mnuFileTotal.Text = "&Total game"
'
'mnuFileBar
'
Me.mnuFileBar.Index = 2
Me.mnuFileBar.Text = "-"
'
'mnuFileExit
'
Me.mnuFileExit.Index = 3
Me.mnuFileExit.Shortcut = System.Windows.Forms.Shortcut.CtrlE
Me.mnuFileExit.Text = "E&xit Game"
'
'mnuHelp
'
Me.mnuHelp.Index = 1
Me.mnuHelp.MenuItems.AddRange(New System.Windows.Forms.MenuItem() {Me.mnuHelpAbout})
Me.mnuHelp.Text = "&Help"
'
'mnuHelpAbout
'
Me.mnuHelpAbout.Index = 0
Me.mnuHelpAbout.Text = "&About Tic-Tac-Toe"
'
'frmTicTacToe
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(520, 613)
Me.Controls.Add(Me.picTie)
Me.Controls.Add(Me.btnExit)
Me.Controls.Add(Me.picTurn)
Me.Controls.Add(Me.picSun)
Me.Controls.Add(Me.picEarth)
Me.Controls.Add(Me.btnReset)
Me.Controls.Add(Me.picMark9)
Me.Controls.Add(Me.picMark8)
Me.Controls.Add(Me.picMark7)
Me.Controls.Add(Me.picMark6)
Me.Controls.Add(Me.picMark5)
Me.Controls.Add(Me.picMark4)
Me.Controls.Add(Me.picMark3)
Me.Controls.Add(Me.picMark2)
Me.Controls.Add(Me.picMark1)
Me.Controls.Add(Me.Label5)
Me.Controls.Add(Me.Label4)
Me.Controls.Add(Me.Label3)
Me.Controls.Add(Me.Label2)
Me.Controls.Add(Me.lblTurn)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle
Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
Me.Menu = Me.MainMenu1
Me.Name = "frmTicTacToe"
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
Me.Text = "Tic - Tac - Toe Problem"
Me.ResumeLayout(False)
End Sub
#End Region
Dim EarthTurn As Boolean 'if True, it's Earth's turn
Dim CanClick As Boolean 'if Turn, can click grid
Dim NumberClicks As Integer 'Number of grid clicks
Dim Marker(9) As Integer 'what marker is in what location(1-Earth,2-Sun)
Private Sub btnReset_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnReset.Click
Dim I As Integer
picMark1.Image = Nothing
picMark2.Image = Nothing
picMark3.Image = Nothing
picMark4.Image = Nothing
picMark5.Image = Nothing
picMark6.Image = Nothing
picMark7.Image = Nothing
picMark8.Image = Nothing
picMark9.Image = Nothing
For I = 1 To 9
Marker(I) = 0
Next I
'make it earth's turn
picTurn.Image = picEarth.Image
lblTurn.Text = "Tutn"
EarthTurn = True
CanClick = True
NumberClicks = 0
End Sub
Private Sub frmTicTacToe_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
btnReset.PerformClick()
End Sub
Private Sub picMark_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles picMark1.Click, _
picMark2.Click, picMark3.Click, picMark4.Click, picMark5.Click, picMark6.Click, picMark7.Click, _
picMark8.Click, picMark9.Click
'Decide which picture was clicked(1-9)
Dim picClicked As PictureBox, Index As Integer
Dim Win As Boolean
picClicked = CType(sender, PictureBox)
'Index is last digit of control name
Index = CInt(Val(Mid(picClicked.Name, Len(picClicked.Name), 1)))
'if can't click or mark already there exit sub
If Not (CanClick) Or Marker(Index) <> 0 Then
Exit Sub
End If
'increment click then mark
NumberClicks = NumberClicks + 1
If EarthTurn Then
Marker(Index) = 1
picClicked.Image = picEarth.Image
Else : Marker(Index) = 2
picClicked.Image = picSun.Image
End If
Win = False
'check for win
If Marker(1) = Marker(Index) And Marker(2) = Marker(Index) And Marker(3) = Marker(Index) Then
'top horizontal win
Win = True
ElseIf Marker(4) = Marker(Index) And Marker(5) = Marker(Index) And Marker(6) = Marker(Index) Then
'middle horizontal win
Win = True
ElseIf Marker(7) = Marker(Index) And Marker(8) = Marker(Index) And Marker(9) = Marker(Index) Then
'botton horizontal win
Win = True
ElseIf Marker(1) = Marker(Index) And Marker(4) = Marker(Index) And Marker(7) = Marker(Index) Then
'left vertical win
Win = True
ElseIf Marker(2) = Marker(Index) And Marker(5) = Marker(Index) And Marker(8) = Marker(Index) Then
'middle vertical win
Win = True
ElseIf Marker(3) = Marker(Index) And Marker(6) = Marker(Index) And Marker(9) = Marker(Index) Then
'right vertical win
Win = True
ElseIf Marker(1) = Marker(Index) And Marker(5) = Marker(Index) And Marker(9) = Marker(Index) Then
'top,left down diagonal win
Win = True
ElseIf Marker(7) = Marker(Index) And Marker(5) = Marker(Index) And Marker(3) = Marker(Index) Then
'bottom, left up diagonal win
Win = True
End If
If Win Then
' there's a win
lblTurn.Text = "Win!!!"
CanClick = False
Else
'if we got this far, this was no win
If NumberClicks < 9 Then
EarthTurn = Not (EarthTurn)
If EarthTurn Then
picTurn.Image = picEarth.Image
Else
picTurn.Image = picSun.Image
End If
Else
'If there's nine clicks and no win, it's a tie
picTurn.Image = picTie.Image
lblTurn.Text = "A Tie ...."
CanClick = False
End If
End If
End Sub
Private Sub btnExit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExit.Click
Dim response As DialogResult
response = MessageBox.Show("Are you sure you want to exit ?", "Exit Game", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If response = DialogResult.Yes Then
Me.Close()
Else : Exit Sub
End If
End Sub
Private Sub mnuFileNew_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuFileNew.Click
Dim I As Integer
Dim Message As String
Dim Response As DialogResult
Response = MessageBox.Show("Are you sure you want to start new game ?", "Exit Game", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Response = DialogResult.Yes Then
picMark1.Image = Nothing
picMark2.Image = Nothing
picMark3.Image = Nothing
picMark4.Image = Nothing
picMark5.Image = Nothing
picMark6.Image = Nothing
picMark7.Image = Nothing
picMark8.Image = Nothing
picMark9.Image = Nothing
For I = 1 To 9
Marker(I) = 0
Next I
Else
Exit Sub
End If
'make it earth's turn
picTurn.Image = picEarth.Image
lblTurn.Text = "Tutn"
EarthTurn = True
CanClick = True
NumberClicks = 0
End Sub
Private Sub mnuHelpAbout_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuHelpAbout.Click
Dim Myform As New frmAbout
Myform.Show()
End Sub
Private Sub mnuFileTotal_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles mnuFileTotal.Click
Static TGame As Integer = 1
Dim Win As Boolean
Dim Message As String
If Win = True Or Win = False Then
TGame += 1
End If
Message = "Total Game : - " + Str(TGame) + ControlChars.Cr
MessageBox.Show(Message, "Statistics", MessageBoxButtons.OK, MessageBoxIcon.Information)
End Sub
End Class
|
|
|
|
|
Since Visual Studio can create different project of Visual Studio VB or Visual Studio C++, can we convert a project Visual Studio VB to project Visual Studio C++? If so how can I do it?
Certain methods will not be converted 100%, but it will be corrected faster than create a new C++ from the scratch!
Thank to any help!
|
|
|
|
|
Google "VB to C++ converter" (you'll see us there and find other useful links).
David Anton
http://www.tangiblesoftwaresolutions.com
C++ to C# Converter
C++ to VB Converter
C++ to Java Converter
C++ to C++/CLI Converter
Instant C#: VB to C# converter
Instant VB: C# to VB converter
Instant C++: converts C# to C++/CLI and VB to C++/CLI
|
|
|
|
|
Do you want to convert your code of VB to VC++?
|
|
|
|
|