Search Results

Search found 10 results on 1 pages for 'd strout'.

Page 1/1 | 1 

  • Using IF statements to find string length in array for alignment (Visual Basic)

    - by Brodoin
    My question is just as it says in the title. How would one use IF statements to find the string-length of content in an array, and then make it so that they show up in a Rich Text Box with the left sides aligned? Noting that one value in my array is a Decimal. Imports System.IO Imports System.Convert Public Class frmAll 'Declare Streamreader Private objReader As StreamReader 'Declare arrays to hold the information Private strNumber(24) As String Private strName(24) As String Private strSize(24) As String Private decCost(24) As Integer Private Sub frmAll_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Set objReader objReader = New StreamReader("products.csv") 'Call the FillArray sub to fill the array Call FillArray() End Sub Private Sub FillArray() 'Declare variables and arrays Dim decCost(24, 1) As Decimal Dim strFields() As String Dim strRec As String Dim intCount As Integer = 0 Dim chrdelim As Char = ToChar(",") 'Set strRec to read the lines strRec = objReader.ReadLine 'Do while loop to fill array. Do While strRec <> Nothing strFields = strRec.Split(chrdelim) strNumber(intCount) = strFields(0) strName(intCount) = strFields(1) strSize(intCount) = strFields(2) decCost(intCount, 0) = ToDecimal(strFields(3)) decCost(intCount, 1) = ToDecimal(strFields(4)) 'Set strRec to read the lines again strRec = objReader.ReadLine 'increment the index intCount += 1 Loop 'Call the Calculate sub for calculation Call Calculate(decCost) End Sub Private Sub Calculate(ByVal numIn(,) As Decimal) 'Define arrays to hold total cost Dim decRowTotal(24) As Decimal 'Define variables to hold the counters for rows and columns Dim intR As Integer Dim intC As Integer 'Calcualte total cost For intC = 0 To 1 For intR = 0 To 24 decRowTotal(intR) += numIn(intR, intC) * 1 Next Next 'Call the Output sub to configure the output. Call Output(numIn, decRowTotal) End Sub Private Sub Output(ByVal NumIn(,) As Decimal, _ ByVal RowTotalIn() As Decimal) 'Variables Dim strOut As String Dim intR As Integer = 0 Dim intC As Integer = 0 'Set header for output. strOut = "ID" & vbTab & "Item" & vbTab & vbTab & vbTab & "Size" & _ vbTab & vbTab & vbTab & vbTab & "Total Price" & _ vbCrLf & "---------- ... -------------------------" & vbCrLf 'For loop to add each line to strOut, setting 'the RowTotalIn to currency. For intC = 0 To 24 strOut &= strNumber(intC) & vbTab strOut &= strName(intC) & vbTab strOut &= strSize(intC) & vbTab strOut &= RowTotalIn(intC).ToString("c") & vbCrLf Next 'Add strOut to rbtAll rtbAll.Text = strOut End Sub End Class Output It shows up with vbTabs in my output, but still, it looks similar in that they are not aligned. The first two do, but after that they are not, and I am totally lost. P0001 Coffee - Colombian Supreme 24/Case: Pre-Ground 1.75 Oz Bags $16.50 P0002 Coffee - Hazelnut 24/Case: Pre-Ground 1.75 Oz Bags $24.00 P0003 Coffee - Mild Blend 24/Case: Pre-Ground 1.75 Oz Bags $20.50 P0004 Coffee - Assorted Flavors 18/Case. Pre-Ground 1.75 Oz Bags $23.50 P0005 Coffee - Decaf 24/Case: Pre-Ground 1.75 Oz Bags $20.50

    Read the article

  • Tieing Fullcalendar into my database

    - by Ed
    I am trying to figure out this fullcalendar and how to get events from database. I am using asp .net I am using a webservice that has something like this. I am just trying to put a test record first then I will tie it to the database once i get it working. Any help would be greatly appreciated! Thanks alot! Just trying to figure out how to tie my webservice. So my webservice goes like so. _ _ _ _ Public Class WebService1 Inherits System.Web.Services.WebService <WebMethod()> _ <ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=True)> _ Public Function Getcalendar() As String Dim sb As New StringBuilder Dim sw As New IO.StringWriter(sb) Dim strOut As String = String.Empty Using writer As New JsonTextWriter(sw) writer.WriteStartObject() writer.WritePropertyName("id") writer.WriteValue("999") writer.WritePropertyName("title") writer.WriteValue("my test") writer.WritePropertyName("allday") writer.WriteValue("false") writer.WritePropertyName("start") writer.WriteValue("2010-04-14T11:00:00") writer.WritePropertyName("end") writer.WriteValue("2010-04-14T13:00:00") writer.WriteEndObject() strOut = sw.ToString End Using Return strOut End Function End Class And my html goes like this <script type="text/javascript"> $(document).ready(function() { $('#calendar').fullCalendar({ header: { left: 'prev,next today', center: 'title', right: 'month,agendaWeek,agendaDay' }, editable: true, events: RVCSC.WebService1.Getcalendar() }); });

    Read the article

  • Fullcalendar tieing into my database

    - by Ed
    I am trying to figure out this fullcalendar and how to get events from database. I am using asp .net I am using a webservice that has something like this. I am just trying to put a test record first then I will tie it to the database once i get it working. Any help would be greatly appreciated! Thanks alot! Just trying to figure out how to tie my webservice. So my webservice goes like so. _ _ _ _ Public Class WebService1 Inherits System.Web.Services.WebService <WebMethod()> _ <ScriptMethod(ResponseFormat:=ResponseFormat.Json, UseHttpGet:=True)> _ Public Function Getcalendar() As String Dim sb As New StringBuilder Dim sw As New IO.StringWriter(sb) Dim strOut As String = String.Empty Using writer As New JsonTextWriter(sw) writer.WriteStartObject() writer.WritePropertyName("id") writer.WriteValue("999") writer.WritePropertyName("title") writer.WriteValue("my test") writer.WritePropertyName("allday") writer.WriteValue("false") writer.WritePropertyName("start") writer.WriteValue("2010-04-14T11:00:00") writer.WritePropertyName("end") writer.WriteValue("2010-04-14T13:00:00") writer.WriteEndObject() strOut = sw.ToString End Using Return strOut End Function End Class And my html goes like this <script type="text/javascript"> $(document).ready(function() { $('#calendar').fullCalendar({ header: { left: 'prev,next today', center: 'title', right: 'month,agendaWeek,agendaDay' }, editable: true, events: RVCSC.WebService1.Getcalendar() }); });

    Read the article

  • Network bridge does not work on Windows 7

    - by D. Strout
    I am trying to use Windows 7 to bridge my wireless and wired connections together to get wireless on a second Windows XP computer (fresh install). The network bridge is created successfully, but when I connect the cable from the first computer with the bridged connections to the second one with just a wired connection, nothing happens. The second computer doesn't connect, and the first computer shows no sign of anything different. I tried bridging the connections of a third computer, and connecting this computer to the second computer. This worked (third computer bridged the wireless to the second computer). Thus, the problem must be with the first (Win 7) computer. However, I have no idea what the problem could be. All Internet Connection Sharing is turned off. Homegroup is disabled (it was originally enabled, I thought that might be a problem, so I disabled it). Also, I had VMWare fusion installed, and that created extra items in the "This connection uses the following items" box in the properties dialog. Thinking this might be causing issues, I uninstalled that too. Still, with everything I tried, I can't get it to work. Any suggestions? Edit: Another thing I noticed that might be worth mentioning: The network icon in the Win7 taskbar has a red X on it that means it's not connected, but when I click the icon, it says connected next to my wireless connection, and I am able to access the internet.

    Read the article

  • Wireless card on HP laptop not working

    - by D. Strout
    I just bought an HP Envy m6-1125dx online from Best Buy. When I got it home and started it up, the wireless card did not work well - at all. I could connect, but any real usage would cause the connection to start dropping every 30 seconds or so, and it would be really slow. Taking another look at the reviews on the Best Buy site, it seems only a few others had this problem, so I took it to my local Best Buy and exchanged it for another unit. Got it home again and the card had the same issues. Which leads to my dilemma. First: does this model have several different cards that it could come with? Mine is a Ralink RT5390R (on both units I received). If it does, then I can keep exchanging until I get a unit with a different card. I wouldn't ask this, except it seems weird that only a few people mentioned this issue, so I thought that might be one possibility. I looked in to replacing the card with a different one myself, but it seems that HP blocks certain wireless cards. However, some people reported success in replacing the card, and this site said it was only an issue on "older HP computer[s]". Can anyone confirm this? Finally, if that fails/will not work, does anyone know what I can get through Best Buy? I am concerned that they will not put any different card than the Ralink, and after two of those, I don't want that. Can I ask Best Buy support to use a different card? Can they even get another card from HP? I guess the base question is: should I attempt to replace the card myself (two days via Amazon to get a new card), should I try to get the laptop repaired through Best Buy (two - four weeks), should I go for a different model laptop from Best Buy, or should I try a different unit of the same model (three's the charm?).

    Read the article

  • iPhone - how to store documents consisting of multiple images?

    - by Joe Strout
    My iPhone (actually, iPad) app creates documents that consist of several images, plus a bit of metadata. What's the best practice for storing these sorts of documents on disk? I see two main options: Create a folder for each document, and store my images as separate PNG files within the folder (plus another little file for the metadata). Create a single file which contains all images and metadata. But I'm not sure how to easily do option 2. I think I can convert my images in PNG format to/from NSData, but then what? I'm still a newbie at Cocoa, but I believe I saw something about stuffing mixed data into some NSSomethingOrOther and having this write itself out to disk, and read itself back in later. Does this ring a bell with anyone? And, will it work with large binary blobs of data like my images? Or would you recommend I simply go with option 1?

    Read the article

  • Open-source generic web service to database interface?

    - by Joe Strout
    I'm looking for a thin, generic layer (probably written in PHP) that sits between a database (probably MySQL) and web service clients (which could be anything). I imagine there would be config files of some sort that tell it how to map web service requests to database queries (or other DB commands). It would also need to handle authentication and authorization, of course. I've done some googling but failed to find anything that fits the bill. Can anyone suggest something like this?

    Read the article

  • Sorting HTML table (with anchor tags and data in cells) in Python

    - by AJ
    I have a necessity to sort a given HTML table of the following structure, in Python. <table> <tr> <td><a href="#">ABCD</a></td> <td>A23BND</td> <td><a title="ABCD">345345</td> </tr> <tr> <td><a href="#">EFG</a></td> <td>Add4D</td> <td><a title="EFG">3432</td> </tr> <tr> <td><a href="#">HG</a></td> <td>GJJ778</td> <td><a title="HG">2341333</td> </tr> </table> I am doing something like this: container = tree.findall("tr") strOut = "" data = [] for elem in container: key = elem.findtext(colName) data.append((key, elem)) data.sort() The problem is that it sorts by the text inside the . I want to be able to sort by the anchor value and not href. What can I do to achieve that? Thanks a lot.

    Read the article

  • net send command program debugging in C#

    - by riad
    Dear all, I write a program to execute and send msg using windows net send command.Its working fine for single receptor.But the problem happen when i want to send message in many receptors. i use a for loop to take receptor name from a list box. Here all message go to the first receptor.The problem happen on process execution.So far i guess the process is not clear or dead on the time. Can any body guide me how i can send the msg to multiple users at a time? my code below: string sendingMessage = messageRichTextBox.Text; string[] recepentAddressArray = new string[recepentAddressListBox.Items.Count]; for (int j = 0; j < recepentAddressListBox.Items.Count; j++) // Getting address from list box { recepentAddressArray[j] = recepentAddressListBox.Items[j].ToString(); string recepantAddress = recepentAddressArray[j]; try { string strLine = "net send " + recepantAddress + " " + sendingMessage + " >C:netsend.log"; FileStream fs = new FileStream("c:netsend.bat", FileMode.Create, FileAccess.Write); StreamWriter streamWriter = new StreamWriter(fs); streamWriter.BaseStream.Seek(0, SeekOrigin.End); streamWriter.Write(strLine); streamWriter.Flush(); streamWriter.Close(); fs.Close(); Process p = new Process(); p.StartInfo.FileName = "C:netsend.bat"; p.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; p.Start(); p.WaitForExit(); p.Close(); FileStream fsOutput = new FileStream("C:netsend.log", FileMode.Open, FileAccess.Read); StreamReader reader = new StreamReader(fsOutput); reader.BaseStream.Seek(0, SeekOrigin.Begin); string strOut = reader.ReadLine(); reader.Close(); fsOutput.Close(); } catch (Exception) { MessageBox.Show("ERROR"); } }

    Read the article

  • Value cannot be null, ArgumentNullException

    - by Wooolie
    I am currently trying to return an array which contains information about a seat at a theate such as Seat number, Name, Price and Status. I am using a combobox where I want to list all vacant or reserved seats based upon choice. When I choose reserved seats in my combobox, I call upon a method using AddRange. This method is supposed to loop through an array containing all seats and their information. If a seat is Vacant, I add it to an array. When all is done, I return this array. However, I am dealing with a ArgumentNullException. MainForm namespace Assignment4 { public partial class MainForm : Form { // private const int totNumberOfSeats = 240; private SeatManager seatMngr; private const int columns = 10; private const int rows = 10; public enum DisplayOptions { AllSeats, VacantSeats, ReservedSeats } public MainForm() { InitializeComponent(); seatMngr = new SeatManager(rows, columns); InitializeGUI(); } /// <summary> /// Fill the listbox with information from the beginning, /// let the user be able to choose from vacant seats. /// </summary> private void InitializeGUI() { rbReserve.Checked = true; txtName.Text = string.Empty; txtPrice.Text = string.Empty; lblTotalSeats.Text = seatMngr.GetNumOfSeats().ToString(); cmbOptions.Items.AddRange(Enum.GetNames(typeof(DisplayOptions))); cmbOptions.SelectedIndex = 0; UpdateGUI(); } /// <summary> /// call on methods ValidateName and ValidatePrice with arguments /// </summary> /// <param name="name"></param> /// <param name="price"></param> /// <returns></returns> private bool ValidateInput(out string name, out double price) { bool nameOK = ValidateName(out name); bool priceOK = ValidatePrice(out price); return nameOK && priceOK; } /// <summary> /// Validate name using inputUtility, show error if input is invalid /// </summary> /// <param name="name"></param> /// <returns></returns> private bool ValidateName(out string name) { name = txtName.Text.Trim(); if (!InputUtility.ValidateString(name)) { //inform user MessageBox.Show("Input of name is Invalid. It can not be empty, " + Environment.NewLine + "and must have at least one character.", " Error!"); txtName.Focus(); txtName.Text = " "; txtName.SelectAll(); return false; } return true; } /// <summary> /// Validate price using inputUtility, show error if input is invalid /// </summary> /// <param name="price"></param> /// <returns></returns> private bool ValidatePrice(out double price) { // show error if input is invalid if (!InputUtility.GetDouble(txtPrice.Text.Trim(), out price, 0)) { //inform user MessageBox.Show("Input of price is Invalid. It can not be less than 0, " + Environment.NewLine + "and must not be empty.", " Error!"); txtPrice.Focus(); txtPrice.Text = " "; txtPrice.SelectAll(); return false; } return true; } /// <summary> /// Check if item is selected in listbox /// </summary> /// <returns></returns> private bool CheckSelectedIndex() { int index = lbSeats.SelectedIndex; if (index < 0) { MessageBox.Show("Please select an item in the box"); return false; } else return true; } /// <summary> /// Call method ReserveOrCancelSeat when button OK is clicked /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnOK_Click(object sender, EventArgs e) { ReserveOrCancelSeat(); } /// <summary> /// Reserve or cancel seat depending on choice the user makes. Update GUI after choice. /// </summary> private void ReserveOrCancelSeat() { if (CheckSelectedIndex() == true) { string name = string.Empty; double price = 0.0; int selectedSeat = lbSeats.SelectedIndex; bool reserve = false; bool cancel = false; if (rbReserve.Checked) { DialogResult result = MessageBox.Show("Do you want to continue?", "Approve", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { if (ValidateInput(out name, out price)) { reserve = seatMngr.ReserveSeat(name, price, selectedSeat); if (reserve == true) { MessageBox.Show("Seat has been reserved"); UpdateGUI(); } else { MessageBox.Show("Seat has already been reserved"); } } } } else { DialogResult result = MessageBox.Show("Do you want to continue?", "Approve", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { cancel = seatMngr.CancelSeat(selectedSeat); if (cancel == true) { MessageBox.Show("Seat has been cancelled"); UpdateGUI(); } else { MessageBox.Show("Seat is already vacant"); } } } UpdateGUI(); } } /// <summary> /// Update GUI with new information. /// </summary> /// <param name="customerName"></param> /// <param name="price"></param> private void UpdateGUI() { lbSeats.Items.Clear(); lbSeats.Items.AddRange(seatMngr.GetSeatInfoString()); lblVacantSeats.Text = seatMngr.GetNumOfVacant().ToString(); lblReservedSeats.Text = seatMngr.GetNumOfReserved().ToString(); if (rbReserve.Checked) { txtName.Text = string.Empty; txtPrice.Text = string.Empty; } } /// <summary> /// set textboxes to false if cancel reservation button is checked /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void rbCancel_CheckedChanged_1(object sender, EventArgs e) { txtName.Enabled = false; txtPrice.Enabled = false; } /// <summary> /// set textboxes to true if reserved radiobutton is checked /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void rbReserve_CheckedChanged_1(object sender, EventArgs e) { txtName.Enabled = true; txtPrice.Enabled = true; } /// <summary> /// Make necessary changes on the list depending on what choice the user makes. Show only /// what the user wants to see, whether its all seats, reserved seats or vacant seats only. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void cmbOptions_SelectedIndexChanged(object sender, EventArgs e) { if (cmbOptions.SelectedIndex == 0 && rbReserve.Checked) //All seats visible. { UpdateGUI(); txtName.Enabled = true; txtPrice.Enabled = true; btnOK.Enabled = true; } else if (cmbOptions.SelectedIndex == 0 && rbCancel.Checked) { UpdateGUI(); txtName.Enabled = false; txtPrice.Enabled = false; btnOK.Enabled = true; } else if (cmbOptions.SelectedIndex == 1) //Only vacant seats visible. { lbSeats.Items.Clear(); lbSeats.Items.AddRange(seatMngr.ReturnVacantSeats()); // Value cannot be null txtName.Enabled = false; txtPrice.Enabled = false; btnOK.Enabled = false; } else if (cmbOptions.SelectedIndex == 2) //Only reserved seats visible. { lbSeats.Items.Clear(); lbSeats.Items.AddRange(seatMngr.ReturnReservedSeats()); // Value cannot be null txtName.Enabled = false; txtPrice.Enabled = false; btnOK.Enabled = false; } } } } SeatManager namespace Assignment4 { class SeatManager { private string[,] nameList = null; private double[,] priceList = null; private string[,] seatList = null; private readonly int totCols; private readonly int totRows; /// <summary> /// Constructor with declarations of size for all arrays. /// </summary> /// <param name="totNumberOfSeats"></param> public SeatManager(int row, int cols) { totCols = cols; totRows = row; nameList = new string[row, cols]; priceList = new double[row, cols]; seatList = new string[row, cols]; for (int rows = 0; rows < row; rows++) { for (int col = 0; col < totCols; col++) { seatList[rows, col] = "Vacant"; } } } /// <summary> /// Check if index is within bounds of the array /// </summary> /// <param name="index"></param> /// <returns></returns> private bool CheckIndex(int index) { if (index >= 0 && index < nameList.Length) return true; else return false; } /// <summary> /// Return total number of seats /// </summary> /// <returns></returns> public int GetNumOfSeats() { int count = 0; for (int rows = 0; rows < totRows; rows++) { for (int cols = 0; cols < totCols; cols++) { count++; } } return count; } /// <summary> /// Calculate and return total number of reserved seats /// </summary> /// <returns></returns> public int GetNumOfReserved() { int totReservedSeats = 0; for (int rows = 0; rows < totRows; rows++) { for (int col = 0; col < totCols; col++) { if (!string.IsNullOrEmpty(nameList[rows, col])) { totReservedSeats++; } } } return totReservedSeats; } /// <summary> /// Calculate and return total number of vacant seats /// </summary> /// <returns></returns> public int GetNumOfVacant() { int totVacantSeats = 0; for (int rows = 0; rows < totRows; rows++) { for (int col = 0; col < totCols; col++) { if (string.IsNullOrEmpty(nameList[rows, col])) { totVacantSeats++; } } } return totVacantSeats; } /// <summary> /// Return formated string with info about the seat, name, price and its status /// </summary> /// <param name="index"></param> /// <returns></returns> public string GetSeatInfoAt(int index) { int cols = ReturnColumn(index); int rows = ReturnRow(index); string strOut = string.Format("{0,2} {1,10} {2,17} {3,20} {4,35:f2}", rows+1, cols+1, seatList[rows, cols], nameList[rows, cols], priceList[rows, cols]); return strOut; } /// <summary> /// Send an array containing all seats in the cinema /// </summary> /// <returns></returns> public string[] GetSeatInfoString() { int count = totRows * totCols; if (count <= 0) return null; string[] strSeatInfoStrings = new string[count]; for (int i = 0; i < totRows * totCols; i++) { strSeatInfoStrings[i] = GetSeatInfoAt(i); } return strSeatInfoStrings; } /// <summary> /// Reserve seat if seat is vacant /// </summary> /// <param name="name"></param> /// <param name="price"></param> /// <param name="index"></param> /// <returns></returns> public bool ReserveSeat(string name, double price, int index) { int cols = ReturnColumn(index); int rows = ReturnRow(index); if (string.IsNullOrEmpty(nameList[rows, cols])) { nameList[rows, cols] = name; priceList[rows, cols] = price; seatList[rows, cols] = "Reserved"; return true; } else return false; } public string[] ReturnVacantSeats() { int totVacantSeats = int.Parse(GetNumOfVacant().ToString()); string[] vacantSeats = new string[totVacantSeats]; for (int i = 0; i < vacantSeats.Length; i++) { if (GetSeatInfoAt(i) == "Vacant") { vacantSeats[i] = GetSeatInfoAt(i); } } return vacantSeats; } public string[] ReturnReservedSeats() { int totReservedSeats = int.Parse(GetNumOfReserved().ToString()); string[] reservedSeats = new string[totReservedSeats]; for (int i = 0; i < reservedSeats.Length; i++) { if (GetSeatInfoAt(i) == "Reserved") { reservedSeats[i] = GetSeatInfoAt(i); } } return reservedSeats; } /// <summary> /// Cancel seat if seat is reserved /// </summary> /// <param name="index"></param> /// <returns></returns> public bool CancelSeat(int index) { int cols = ReturnColumn(index); int rows = ReturnRow(index); if (!string.IsNullOrEmpty(nameList[rows, cols])) { nameList[rows, cols] = ""; priceList[rows, cols] = 0.0; seatList[rows, cols] = "Vacant"; return true; } else { return false; } } /// <summary> /// Convert index to row and return value /// </summary> /// <param name="index"></param> /// <returns></returns> public int ReturnRow(int index) { int vectorRow = index; int row; row = (int)Math.Ceiling((double)(vectorRow / totCols)); return row; } /// <summary> /// Convert index to column and return value /// </summary> /// <param name="index"></param> /// <returns></returns> public int ReturnColumn(int index) { int row = index; int col = row % totCols; return col; } } } In MainForm, this is where I get ArgumentNullException: lbSeats.Items.AddRange(seatMngr.ReturnVacantSeats()); And this is the method where the array is to be returned containing all vacant seats: public string[] ReturnVacantSeats() { int totVacantSeats = int.Parse(GetNumOfVacant().ToString()); string[] vacantSeats = new string[totVacantSeats]; for (int i = 0; i < vacantSeats.Length; i++) { if (GetSeatInfoAt(i) == "Vacant") { vacantSeats[i] = GetSeatInfoAt(i); } } return vacantSeats; }

    Read the article

1