Commit 46bbc3e5 authored by O'Reilly Media, Inc.'s avatar O'Reilly Media, Inc.
Browse files

Initial commit

parents
Loading
Loading
Loading
Loading

9780596101770

0 → 120000
+1 −0
Changes for 9780596101770: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
9780596101770
 No newline at end of file
+92 −0
Changes for Chapter 01 Source Code/Console Version/ConvertTemperature.vbproj: 92 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <PropertyGroup>
    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
    <ProductVersion>8.0.50727</ProductVersion>
    <SchemaVersion>2.0</SchemaVersion>
    <ProjectGuid>{C09BCC1C-1087-48BE-8BE9-C4A812FFCE92}</ProjectGuid>
    <OutputType>Exe</OutputType>
    <StartupObject>ConsoleApplication1.ConvertTemperature</StartupObject>
    <RootNamespace>ConsoleApplication1</RootNamespace>
    <AssemblyName>ConvertTemperature</AssemblyName>
    <MyType>Console</MyType>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
    <DebugSymbols>true</DebugSymbols>
    <DebugType>full</DebugType>
    <DefineDebug>true</DefineDebug>
    <DefineTrace>true</DefineTrace>
    <OutputPath>bin\Debug\</OutputPath>
    <DocumentationFile>ConvertTemperature.xml</DocumentationFile>
    <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
  </PropertyGroup>
  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
    <DebugType>pdbonly</DebugType>
    <DefineDebug>false</DefineDebug>
    <DefineTrace>true</DefineTrace>
    <Optimize>true</Optimize>
    <OutputPath>bin\Release\</OutputPath>
    <DocumentationFile>ConvertTemperature.xml</DocumentationFile>
    <NoWarn>42016,41999,42017,42018,42019,42032,42036,42020,42021,42022</NoWarn>
  </PropertyGroup>
  <ItemGroup>
    <Reference Include="System" />
    <Reference Include="System.Data" />
    <Reference Include="System.Deployment" />
    <Reference Include="System.Xml" />
  </ItemGroup>
  <ItemGroup>
    <Import Include="Microsoft.VisualBasic" />
    <Import Include="System" />
    <Import Include="System.Collections" />
    <Import Include="System.Collections.Generic" />
    <Import Include="System.Data" />
    <Import Include="System.Diagnostics" />
  </ItemGroup>
  <ItemGroup>
    <Compile Include="Module1.vb" />
    <Compile Include="My Project\AssemblyInfo.vb" />
    <Compile Include="My Project\Application.Designer.vb">
      <AutoGen>True</AutoGen>
      <DependentUpon>Application.myapp</DependentUpon>
    </Compile>
    <Compile Include="My Project\Resources.Designer.vb">
      <AutoGen>True</AutoGen>
      <DesignTime>True</DesignTime>
      <DependentUpon>Resources.resx</DependentUpon>
    </Compile>
    <Compile Include="My Project\Settings.Designer.vb">
      <AutoGen>True</AutoGen>
      <DependentUpon>Settings.settings</DependentUpon>
      <DesignTimeSharedInput>True</DesignTimeSharedInput>
    </Compile>
  </ItemGroup>
  <ItemGroup>
    <EmbeddedResource Include="My Project\Resources.resx">
      <Generator>VbMyResourcesResXFileCodeGenerator</Generator>
      <LastGenOutput>Resources.Designer.vb</LastGenOutput>
      <CustomToolNamespace>My.Resources</CustomToolNamespace>
      <SubType>Designer</SubType>
    </EmbeddedResource>
  </ItemGroup>
  <ItemGroup>
    <None Include="My Project\Application.myapp">
      <Generator>MyApplicationCodeGenerator</Generator>
      <LastGenOutput>Application.Designer.vb</LastGenOutput>
    </None>
    <None Include="My Project\Settings.settings">
      <Generator>SettingsSingleFileGenerator</Generator>
      <CustomToolNamespace>My</CustomToolNamespace>
      <LastGenOutput>Settings.Designer.vb</LastGenOutput>
    </None>
  </ItemGroup>
  <Import Project="$(MSBuildBinPath)\Microsoft.VisualBasic.targets" />
  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
       Other similar extension points exist, see Microsoft.Common.targets.
  <Target Name="BeforeBuild">
  </Target>
  <Target Name="AfterBuild">
  </Target>
  -->
</Project>
 No newline at end of file
+83 −0
Changes for Chapter 01 Source Code/Console Version/Module1.vb: 83 added lines, 0 removed lines.
Original line number Diff line number Diff line
Module ConvertTemperature

    Sub Main()
        ' ----- The program starts here.
        Dim userInput As String
        Dim sourceType As String

        On Error Resume Next

        ' ----- Display general instructions.
        Console.WriteLine("Instructions:" & vbCrLf & _
            "To convert temperature, enter a starting temperature, followed" & vbCrLf & _
            "by one of the following letters:" & vbCrLf & _
            "  F = Fahrenheit" & vbCrLf & _
            "  C = Celsius" & vbCrLf & _
            "  K = kelvin" & vbCrLf & _
            "Enter a blank line to exit." & vbCrLf)

        ' ----- The program continues until the user enters a blank line.
        Do While True
            ' ----- Prompt the user.
            Console.WriteLine("Enter a source temperature.")
            Console.Write("> ")
            userInput = Console.ReadLine()

            ' ----- A blank line exits the application.
            If (Trim(userInput) = "") Then Exit Do

            ' ----- Determine the source type.
            userInput = UCase(userInput)
            If (InStr(userInput, "F") > 0) Then
                ' ----- Start with Fahrenheit.
                sourceType = "F"
                userInput = Replace(userInput, "F", "")
            ElseIf (InStr(userInput, "C") > 0) Then
                ' ----- Start with Celsius.
                sourceType = "C"
                userInput = Replace(userInput, "C", "")
            ElseIf (InStr(userInput, "K") > 0) Then
                ' ----- Start with kelvin.
                sourceType = "K"
                userInput = Replace(userInput, "K", "")
            Else
                ' ----- Invalid entry.
                Console.WriteLine("Invalid input: " & userInput & vbCrLf)
                Continue Do
            End If

            ' ----- Check for a valid temperature.
            userInput = Trim(userInput)
            If (IsNumeric(userInput) = False) Then
                Console.WriteLine("Invalid number: " & userInput & vbCrLf)
                Continue Do
            End If

            ' ----- Time to convert.
            If (sourceType = "F") Then
                ' ----- Convert from Fahrenheit to other types.
                Console.WriteLine("  Fahrenheit: " & userInput)
                Console.WriteLine("  Celsius:    " & _
                    (Val(userInput) - 32) / 1.8)
                Console.WriteLine("  kelvin:     " & _
                    ((Val(userInput) - 32) / 1.8) + 273.15)
            ElseIf (sourceType = "C") Then
                ' ----- Convert from Celsius to other types.
                Console.WriteLine("  Fahrenheit: " & _
                    (Val(userInput) * 1.8) + 32)
                Console.WriteLine("  Celsius:    " & userInput)
                Console.WriteLine("  kelvin:     " & _
                    Val(userInput) + 273.15)
            Else
                ' ----- Convert from kelvin to other types.
                Console.WriteLine("  Fahrenheit: " & _
                    ((Val(userInput) - 273.15) * 1.8) + 32)
                Console.WriteLine("  Celsius:    " & _
                    Val(userInput) - 273.15)
                Console.WriteLine("  kelvin:     " & userInput)
            End If
        Loop
        End
    End Sub

End Module
+13 −0
Changes for Chapter 01 Source Code/Console Version/My Project/Application.Designer.vb: 13 added lines, 0 removed lines.
Original line number Diff line number Diff line
'------------------------------------------------------------------------------
' <auto-generated>
'     This code was generated by a tool.
'     Runtime Version:2.0.50727.42
'
'     Changes to this file may cause incorrect behavior and will be lost if
'     the code is regenerated.
' </auto-generated>
'------------------------------------------------------------------------------

Option Strict On
Option Explicit On
+10 −0
Changes for Chapter 01 Source Code/Console Version/My Project/Application.myapp: 10 added lines, 0 removed lines.
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<MyApplicationData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <MySubMain>false</MySubMain>
  <SingleInstance>false</SingleInstance>
  <ShutdownMode>0</ShutdownMode>
  <EnableVisualStyles>true</EnableVisualStyles>
  <AuthenticationMode>0</AuthenticationMode>
  <ApplicationType>2</ApplicationType>
  <SaveMySettingsOnExit>true</SaveMySettingsOnExit>
</MyApplicationData>
Loading